Marcel Moolenaar wrote:
> On Tue, Nov 05, 2002 at 03:17:24AM -0800, Maxime Henrion wrote:
> > Juli Mallett wrote:
> > > * De: Maxime Henrion <[EMAIL PROTECTED]> [ Data: 2002-11-05 ]
> > >   [ Subjecte: Re: uuid.h is not C++ safe ]
> > > > Maxime Henrion wrote:
> > > > > Patrick Hartling wrote:
> > > > > > I was just about to put the new DCE 1.1 UUID functions into use in some 
> > > > > > C++ code, but linking fails because the function prototypes in uuid.h 
> > > > > > are not protected with the __cplusplus/extern "C" bits.  It's easy 
> > > > > > enough for me to fix my local copy, but I'm sure this same thing could 
> > > > > > trip up other people.
> > > > > 
> > > > > This should be fixed with the attached patch.  Marcel, can you review
> > > > > and commit it please ?
> > > 
> > > Oops, I probably should have pinged Marcel about this, now that I think
> > > about it, but anyway, it shouldn't change anything.  Even with vanilla
> > > cpp(1) both produce the right thing, with or without __cplusplus defined,
> > > and both produce the identical thing (moins linenos/whitespace) in the
> > > C case.
> > > 
> > > Of course, both <uuid.h> and <sys/uuid.h> needed changed, as both
> > > define protos, and <sys/uuid.h> is included into <uuid.h>.
> > 
> > That's arguably bad, sys/uuid.h shouldn't have any !_KERNEL prototypes
> > in it.
> 
> If there's a better place, then we should move it. We could put it in
> <uuid.h>, but I don't want to make that header a requirement if one
> only uses the syscall. I don't yet know what a good place would be,
> if not <sys/uuid.h>. Suggestions?

Well I don't really understand what you mean here.  Since this prototype
is #ifndef _KERNEL in sys/sys/uuid.h and since this header is included by
lib/libc/uuid/uuid.h, moving it into the libc header shouldn't make any
difference both in visibility and header requirements.  That's also how
we generally do for other syscalls.  The attached (and untested) patch
does it.

Am I missing something with respect to your concerns about this ?

Cheers,
Maxime
Index: lib/libc/uuid/uuid.h
===================================================================
RCS file: /space2/ncvs/src/lib/libc/uuid/uuid.h,v
retrieving revision 1.2
diff -u -p -r1.2 uuid.h
--- lib/libc/uuid/uuid.h        5 Nov 2002 10:55:16 -0000       1.2
+++ lib/libc/uuid/uuid.h        5 Nov 2002 23:40:14 -0000
@@ -30,6 +30,7 @@
 #ifndef _UUID_H_
 #define        _UUID_H_
 
+#include <sys/cdefs.h>
 #include <sys/types.h>
 #include <sys/uuid.h>
 
@@ -45,7 +46,11 @@
 #define        uuid_s_invalid_string_uuid      2
 #define        uuid_s_no_memory                3
 
+/* XXX namespace pollution? */
+typedef struct uuid uuid_t;
+
 __BEGIN_DECLS
+int    uuidgen(struct uuid *, int);
 int32_t        uuid_compare(uuid_t *, uuid_t *, uint32_t *);
 void   uuid_create(uuid_t *, uint32_t *);
 void   uuid_create_nil(uuid_t *, uint32_t *);
Index: sys/sys/uuid.h
===================================================================
RCS file: /space2/ncvs/src/sys/sys/uuid.h,v
retrieving revision 1.2
diff -u -p -r1.2 uuid.h
--- sys/sys/uuid.h      5 Nov 2002 10:57:53 -0000       1.2
+++ sys/sys/uuid.h      5 Nov 2002 23:38:44 -0000
@@ -29,8 +29,6 @@
 #ifndef _SYS_UUID_H_
 #define        _SYS_UUID_H_
 
-#include <sys/cdefs.h>
-
 /* Length of a node address (an IEEE 802 address). */
 #define        _UUID_NODE_LEN          6
 
@@ -50,8 +48,6 @@ struct uuid {
        uint8_t         node[_UUID_NODE_LEN];
 };
 
-#ifdef _KERNEL
-
 #define        UUID_NODE_LEN   _UUID_NODE_LEN
 
 struct sbuf;
@@ -59,16 +55,5 @@ struct sbuf;
 int snprintf_uuid(char *, size_t, struct uuid *);
 int printf_uuid(struct uuid *);
 int sbuf_printf_uuid(struct sbuf *, struct uuid *);
-
-#else  /* _KERNEL */
-
-/* XXX namespace pollution? */
-typedef struct uuid uuid_t;
-
-__BEGIN_DECLS
-int    uuidgen(struct uuid *, int);
-__END_DECLS
-
-#endif /* _KERNEL */
 
 #endif /* _SYS_UUID_H_ */

Reply via email to