X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:reply-to :references:mime-version:content-type:in-reply-to; q=dns; s= default; b=kSEvxOTjNThi43vjaz3Sr7k7ZBhdtKIJwP4qEWDsrqQSeAPWN5CDH qiwG8jy/S8zkb2FeIvGDyWXarVMhtElwVeXM9aU226m46gGVwX7MmAoePdbPJ8PM 0GzAlztv4Zqwt/nI3etJFB1K0IiW8v9VHI/AcKVNIopvFxqec7X/As= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:reply-to :references:mime-version:content-type:in-reply-to; s=default; bh=gCUBllT9ZQomX9q/J/I7r2wg2J4=; b=O4JghqpezS5El9wrGHIUrzwg9/YS v3pDtLNI3N6I4WD55nW3xRT2S/qPNg33Vl1zvDVinmhriIYD39iBUaQ39/tOpQoD a4hMzPzserw5bZ1rqXQQK+hc6WSqBdwhL+8wXCDr/lHOQFDvMw57xZXgrEl66Er3 ZYzOXAkPojWWvgo= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.6 required=5.0 tests=AWL,BAYES_00,EXCEL_ATTACHED,KAM_LAZY_DOMAIN_SECURITY,UNSUBSCRIBE_BODY autolearn=no version=3.3.2 X-HELO: calimero.vinschen.de Date: Sun, 12 Apr 2015 14:18:05 +0200 From: Corinna Vinschen To: cygwin AT cygwin DOT com Subject: Re: Shared memory handling for mixed C/FORTRAN program Message-ID: <20150412121805.GQ7343@calimero.vinschen.de> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com References: <1999567694 DOT 2259208 DOT 1428493743005 DOT JavaMail DOT yahoo AT mail DOT yahoo DOT com> <1457851220 DOT 1207684 DOT 1428783910446 DOT JavaMail DOT yahoo AT mail DOT yahoo DOT com> <20150412112325 DOT GP7343 AT calimero DOT vinschen DOT de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="XLsjFikA86nwwlhe" Content-Disposition: inline In-Reply-To: <20150412112325.GP7343@calimero.vinschen.de> User-Agent: Mutt/1.5.23 (2014-03-12) --XLsjFikA86nwwlhe Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Apr 12 13:23, Corinna Vinschen wrote: > On Apr 11 20:25, Christoph Weise wrote: > > Please see below, I provide minimal C code for three separate > > executables, one creates the shm section, another finds it, the third > > removes it. I include also a bash test script that executes the > > routines in order. >=20 > Thanks, >=20 > > Please beware as I removed some checks to reduce > > the length of the code, but it should run ok. The PAGESIZE parameter > > is hardcoded (here 512 bytes). The desired shared mem section size is > > set interactively as input to makeshm, or automatically with the bash > > script.=20 >=20 > Ok, but there are bugs in the code which result in GCC warnings. I > don't know which of them are part of your original code, but they are > really a problem. >=20 > if ((int) -1 =3D=3D p) >=20 > Don't check a pointer against an int value. It won't work on a 64 bit > platform. Make that >=20 > if ((void *) -1 =3D=3D p) >=20 > For the same reason, don't use %x to printf a pointer. Use %tx. >=20 > > I can write to the shm section with the second routine when the request= ed section <=3D 4096 bytes. Otherwise it's not happy.=20 >=20 > The problem is the call to shmget: >=20 > #undef PAGESIZE > #define PAGESIZE 512 > shmid =3D shmget(key, PAGESIZE, IPC_ALLOC); >=20 > Since you're requesting only 512 bytes, the shared memory segment the > following shmat call returns is only 4K. The shmget call should request > as much memory as it needs so that the OS call is called with the right > view size. >=20 > I re-read the POSIX man page for shmget, and it doesn't mention anything > which would point out that Cygwin's behaviour here is wrong. If anybody > has more information on this, please share them. On second thought, adjusting Cygwin's behaviour to Linux here is rather trivial. I applied a patch to the git repo and uploaded new developer snapshots (2015-04-12) to https://cygwin.com/snapshots/ You only have to replace the DLL itself, cygserver is not affected by this patch. Please give it a try. Thanks, Corinna --=20 Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat --XLsjFikA86nwwlhe Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBAgAGBQJVKmJ9AAoJEPU2Bp2uRE+g0qwQAJR/9gmaPZw5fwSRlGkftL8M 2tUTpi9uHOe9ezRGR4FZNTRxG5IDFvh8V7bpJ2pedvlZlVrQHIW1WEGp2tQ8PLaL J7C/xI98/P+Imo2yKXmpf4Z7CnvDltLhXnR3SAV6fuXadTjdtIAllSOnBeQrHAsJ Xz53OOfzgaJJQLDjqOQNo3LiXCjupIjkq19v+5AKkCptpaMo5al39WZUY165a7Ep l84c+MzaXghUZGAj3acCBtJjAB22zhAJKvcMmKrwzppGFIWFLcvhSTi5jUkd8EHw UIskTBgTI3IjkyRXtYbiJJm67q98hzUZ51X+CUIlx7oF0H6aMora74A7JWGI/UH9 uku0YFX2iSmX0fadxlGtaWOgQPFDbP+DN7IFJgqbJuerp606aV1+M2HEY8GFWIbo QElUNQEtIZcjZva26mBMfi9w72OoIYT4GWQ+iwir2DaBm9+SqGVQdAccvH4RW96j NkcrLnQVmcGtHCBrLoUDMwFFVk2VSG0XG5ysqsg8Hk0yqqgWG2fFNDbdGPJXayDK odgGkAzxCyrIjT1QEKGGJe4xrGkH53B6gutSSVNVB5gKD9Td1/PkmoB1a+xfPpgC UDx1X6Kfraei6CDaiHbP79kTCsXb0EhwE5TMSQC2XwzcFP7eTVU0ZBYSEJfzPgWi C7ZxFM8CUzk/xrLRbGDS =7Y6I -----END PGP SIGNATURE----- --XLsjFikA86nwwlhe--