www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14007] New: shmctl with IPC_STAT returns wrong number of

https://issues.dlang.org/show_bug.cgi?id=14007

          Issue ID: 14007
           Summary: shmctl with IPC_STAT returns wrong number of
                    attachments. shmid_ds is defined wrong.
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: 10l94s+31wgxrstmw2bk sharklasers.com

Created attachment 1464
  --> https://issues.dlang.org/attachment.cgi?id=1464&action=edit
D codes with solution

I have written a simple code to create a shared memory segment (shmget).

Then attached it (shmat), and got the statistics information for that shared
memory.

According to documentation of shmat, number of attachments (shm_nattch) should
be 1.

I wrote same code in both C and D. C returns 1, D return 0.

C's shmid_ds is defined in /usr/include/bits/shm.h
D's shmid_ds is defined in core.sys.posix.sys.shm

C's definition contains conditionals for 64 bit systems.
D has definition for Linux only, no Posix. And its definition is done for
32-bit systems only.

I then defined the shmid_ds myself with conditional by using "version". Finally
it is solved. I attached the working solution. "dmd main-works.d" will do it.

I am not familiar with merge requests. So I am putting it here.

--
Jan 18 2015