Bug 74751 - swab() should be declared in <unistd.h>, not <string.h>
Summary: swab() should be declared in <unistd.h>, not <string.h>
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: standards (show other bugs)
Version: 6.0-CURRENT
Hardware: Any Any
: Normal Affects Only Me
Assignee: Tom Rhodes
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-12-06 01:50 UTC by Craig Rodrigues
Modified: 2005-06-27 02:55 UTC (History)
0 users

See Also:


Attachments
file.diff (1.65 KB, patch)
2004-12-06 01:50 UTC, Craig Rodrigues
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Craig Rodrigues 2004-12-06 01:50:15 UTC
I was trying to compile the ACE library, which follows
the Single Unix Specification fairly closesly, and compilation
failed because our swab() is declared in <string.h>, not in <unistd.h>.

The prototype for swab() should be in <unistd.h>, not in <string.h>,
according to:
http://www.opengroup.org/onlinepubs/009695399/functions/swab.html
Comment 1 Craig Rodrigues 2004-12-06 04:44:20 UTC
Hi,

This is a more correct patch, to match
the prototype in SUS.
At some point this prototype should be removed
from string.h, but I left it in there, in case
we want to preserve some backwards compatibility.
-- 
Craig Rodrigues        
rodrigc@crodrigues.org



--- ./include/string.h.orig	Sun Dec  5 20:24:50 2004
+++ ./include/string.h	Sun Dec  5 23:25:56 2004
@@ -108,8 +108,19 @@
 #endif
 size_t	 strxfrm(char * __restrict, const char * __restrict, size_t);
 #if __BSD_VISIBLE
-void	 swab(const void *, void *, size_t);
-#endif
+
+#ifndef _SWAB_DECLARED
+#define _SWAB_DECLARED
+
+#ifndef _SSIZE_T_DECLARED
+typedef	__ssize_t	ssize_t;
+#define	_SSIZE_T_DECLARED
+#endif /* _SIZE_T_DECLARED */
+
+void	 swab(const void * __restrict, void * __restrict, ssize_t);
+#endif /* _SWAB_DECLARED */
+
+#endif /* __BSD_VISIBLE */
 __END_DECLS
 
 #endif /* _STRING_H_ */
--- ./include/unistd.h.orig	Sun Dec  5 20:29:04 2004
+++ ./include/unistd.h	Sun Dec  5 20:32:11 2004
@@ -436,7 +436,12 @@
 int	 setpgrp(pid_t _pid, pid_t _pgrp); /* obsoleted by setpgid() */
 int	 setregid(gid_t, gid_t);
 int	 setreuid(uid_t, uid_t);
-/* void	 swab(const void * __restrict, void * __restrict, ssize_t); */
+
+#ifndef _SWAB_DECLARED
+#define _SWAB_DECLARED
+void	 swab(const void * __restrict, void * __restrict, ssize_t);
+#endif /* _SWAB_DECLARED */
+
 void	 sync(void);
 useconds_t	 ualarm(useconds_t, useconds_t);
 int	 usleep(useconds_t);
--- ./lib/libc/string/swab.c.orig	Sun Dec  5 20:21:03 2004
+++ ./lib/libc/string/swab.c	Sun Dec  5 23:11:39 2004
@@ -40,10 +40,10 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/lib/libc/string/swab.c,v 1.5 2002/08/30 20:33:05 robert Exp $");
 
-#include <string.h>
+#include <unistd.h>
 
 void
-swab(const void * __restrict from, void * __restrict to, size_t len)
+swab(const void * __restrict from, void * __restrict to, ssize_t len)
 {
 	unsigned long temp;
 	int n;
--- ./lib/libc/string/swab.3.orig	Sun Dec  5 20:22:22 2004
+++ ./lib/libc/string/swab.3	Sun Dec  5 23:22:00 2004
@@ -41,9 +41,9 @@
 .Sh LIBRARY
 .Lb libc
 .Sh SYNOPSIS
-.In string.h
+.In unistd.h
 .Ft void
-.Fn swab "const void * restrict src" "void * restrict dst" "size_t len"
+.Fn swab "const void * restrict src" "void * restrict dst" "ssize_t len"
 .Sh DESCRIPTION
 The function
 .Fn swab
Comment 2 Tom Rhodes freebsd_committer freebsd_triage 2004-12-10 15:55:52 UTC
State Changed
From-To: open->patched

Patch committed 


Comment 3 Tom Rhodes freebsd_committer freebsd_triage 2004-12-10 15:55:52 UTC
Responsible Changed
From-To: freebsd-standards->trhodes

Over to me.
Comment 4 Matteo Riondato 2005-04-08 20:52:54 UTC
This was not merged to RELENG_5 nor to RELENG_4.
If and after the merge has happened, this PR can be closed.
Thanks
Best Regards
-- 
Rionda aka Matteo Riondato
Disinformato per default
G.U.F.I. Staff Member (http://www.gufi.org)
FreeSBIE Developer (http://www.freesbie.org)
Comment 5 Tom Rhodes freebsd_committer freebsd_triage 2005-06-27 02:54:58 UTC
State Changed
From-To: patched->closed

MFC complete, thanks for the submission!