This is the mail archive of the mailing list for the newlib project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v3 2/2] Add BSD guards for off_t, dev_t, uid_t, and gid_t

On Apr 13 13:10, Sebastian Huber wrote:
> Copy definitions of off_t, dev_t, uid_t, and gid_t verbatim from latest
> FreeBSD <sys/types.h>.

Patches look good.

Below is a followup patch to get rid of Cygwin special handling.

Basically it introduces machine/_types.h in Cygwin, plus it also
handles key_t just like the other types in _types.h and types.h.

It works AFAICS, but I'd be glad if you could take a look if I
didn't screw up something.

Independently of the below patch, what about mode_t?  Right now it's
an RTEMS special:

  #if defined(__rtems__)
  typedef _mode_t mode_t;

Shouldn't we generalize this one as well?


diff --git a/newlib/libc/include/sys/_types.h b/newlib/libc/include/sys/_types.h
index b38a161..c12eca3 100644
--- a/newlib/libc/include/sys/_types.h
+++ b/newlib/libc/include/sys/_types.h
@@ -45,6 +45,10 @@ typedef _off_t __off_t;
 typedef _off64_t __loff_t;
+#ifndef __key_t_defined
+typedef long __key_t;
  * We need fpos_t for the following, but it doesn't have a leading "_",
  * so we use _fpos_t instead.
diff --git a/newlib/libc/include/sys/types.h b/newlib/libc/include/sys/types.h
index 496c2ae..316ee9a 100644
--- a/newlib/libc/include/sys/types.h
+++ b/newlib/libc/include/sys/types.h
@@ -167,7 +167,6 @@ typedef int32_t register_t;
  * how the file was compiled (e.g. -mint16 vs -mint32, etc.).
-#ifndef __CYGWIN__	/* which defines these types in it's own types.h. */
 #ifndef _OFF_T_DECLARED
 typedef	__off_t		off_t;		/* file offset */
 #define	_OFF_T_DECLARED
@@ -184,7 +183,6 @@ typedef	__uid_t		uid_t;		/* user id */
 typedef	__gid_t		gid_t;		/* group id */
 #define	_GID_T_DECLARED
-#endif /* !__CYGWIN__ */
 #ifndef _PID_T_DECLARED
 typedef	__pid_t		pid_t;		/* process id */
@@ -195,8 +193,9 @@ typedef	__pid_t		pid_t;		/* process id */
 typedef _mode_t mode_t;
-#ifndef __CYGWIN__
-typedef	long key_t;
+#ifndef _KEY_T_DECLARED
+typedef	__key_t		key_t;		/* IPC key */
+#define	_KEY_T_DECLARED
diff --git a/winsup/cygwin/include/cygwin/types.h b/winsup/cygwin/include/cygwin/types.h
index bdf4085..f9ed4b6 100644
--- a/winsup/cygwin/include/cygwin/types.h
+++ b/winsup/cygwin/include/cygwin/types.h
@@ -32,19 +32,8 @@ typedef struct timespec timespec_t;
 typedef struct timespec timestruc_t;
 #endif /*__timestruc_t_defined*/
-#ifndef __off_t_defined
-#define __off_t_defined
-typedef __off_t off_t;
-#endif /*__off_t_defined*/
 typedef __loff_t loff_t;
-#ifndef __dev_t_defined
-#define __dev_t_defined
-typedef __int16_t __dev16_t;
-typedef __uint32_t dev_t;
-#endif /*__dev_t_defined*/
 #ifndef __blksize_t_defined
 #define __blksize_t_defined
 typedef __int32_t blksize_t;
@@ -68,18 +57,6 @@ typedef unsigned long fsblkcnt_t;
 typedef unsigned long fsfilcnt_t;
 #endif /* __fsfilcnt_t_defined */
-#ifndef __uid_t_defined
-#define __uid_t_defined
-typedef unsigned short __uid16_t;
-typedef __uint32_t uid_t;
-#endif /*__uid_t_defined*/
-#ifndef __gid_t_defined
-#define __gid_t_defined
-typedef unsigned short __gid16_t;
-typedef __uint32_t gid_t;
-#endif /*__gid_t_defined*/
 #ifndef __ino_t_defined
 #define __ino_t_defined
 #ifndef __x86_64__
@@ -113,11 +90,6 @@ struct flock {
 	pid_t	 l_pid;		/* returned with F_GETLK */
-#ifndef __key_t_defined
-#define __key_t_defined
-typedef long long key_t;
-#endif /* __key_t_defined */
 #define __BIT_TYPES_DEFINED__ 1
diff --git a/winsup/cygwin/include/machine/_types.h b/winsup/cygwin/include/machine/_types.h
new file mode 100644
index 0000000..aafa998
--- /dev/null
+++ b/winsup/cygwin/include/machine/_types.h
@@ -0,0 +1,26 @@
+/* Cygwin's machine/_types.h */
+#ifndef _MACHINE__TYPES_H
+#define _MACHINE__TYPES_H
+#include <machine/_default_types.h>
+#if defined (__INSIDE_CYGWIN__) || defined (_COMPILING_NEWLIB)
+typedef __int16_t  __dev16_t;
+typedef __uint16_t __uid16_t;
+typedef __uint16_t __gid16_t;
+#define __dev_t_defined
+typedef __uint32_t __dev_t;
+#define __uid_t_defined
+typedef __uint32_t __uid_t;
+#define __gid_t_defined
+typedef __uint32_t __gid_t;
+#define __key_t_defined
+typedef long long __key_t;
+#endif /* _MACHINE__TYPES_H */
diff --git a/winsup/cygwin/include/sys/cygwin.h b/winsup/cygwin/include/sys/cygwin.h
index 8c7128c..e663690 100644
--- a/winsup/cygwin/include/sys/cygwin.h
+++ b/winsup/cygwin/include/sys/cygwin.h
@@ -397,11 +397,9 @@ extern void cygwin_premain3 (int, char **, struct per_process *);
-#ifndef __uid_t_defined
+#ifndef __INSIDE_CYGWIN__
 typedef __uint16_t __uid16_t;
 typedef __uint16_t __gid16_t;
-typedef __uint32_t uid_t;
-typedef __uint32_t gid_t;
 struct external_pinfo

Attachment: signature.asc
Description: PGP signature

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]