According to the information on:

http://www.opengroup.org/onlinepubs/009695399/functions/swab.html
the prototype for swab() should be in <unistd.h> and not in <string.h>.
Move it, and update to match SUS.  Leave the prototype in string.h for
now, for backwards compat.

PR:		74751
Submitted by:	Craig Rodrigues <rodrigc@crodrigues.org>
Discussed with:	das
This commit is contained in:
Tom Rhodes 2004-12-10 15:24:40 +00:00
parent 54bb820a75
commit 2f5cde3c64
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=138659
4 changed files with 23 additions and 7 deletions

View File

@ -108,8 +108,19 @@ char *strtok_r(char *, const char *, char **);
#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_ */

View File

@ -436,7 +436,12 @@ ssize_t pwrite(int, const void *, size_t, off_t);
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);

View File

@ -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

View File

@ -40,10 +40,10 @@ static char sccsid[] = "@(#)swab.c 8.1 (Berkeley) 6/4/93";
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#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;