mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-02-20 09:26:37 +00:00
Fix bcopy()/bzero() #define hack
Replace #define bcopy(...) memset(...) with inline functions only if bcopy() is unavailable, as checked by configure script Ditto bzero()
This commit is contained in:
parent
cb6d65f621
commit
1e61e7a02f
@ -70,7 +70,7 @@ dnl Solaris hides nanosleep here
|
||||
AC_CHECK_LIB(rt,nanosleep)
|
||||
|
||||
dnl BSD way of getting socket creds
|
||||
AC_CHECK_FUNCS(getpeereid)
|
||||
AC_CHECK_FUNCS([getpeereid bcopy bzero])
|
||||
|
||||
AC_CHECK_HEADERS(
|
||||
stdio.h \
|
||||
|
21
os.c
21
os.c
@ -17,11 +17,30 @@ along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#define __SERVALDNA_OS_INLINE
|
||||
#include "os.h"
|
||||
#include "log.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
#include <fcntl.h>
|
||||
#include <alloca.h>
|
||||
#include <dirent.h>
|
||||
#include <time.h>
|
||||
#include "serval.h"
|
||||
#include <string.h>
|
||||
|
||||
#ifndef HAVE_BZERO
|
||||
__SERVALDNA_OS_INLINE void bzero(void *buf, size_t len) {
|
||||
memset(buf, 0, len);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_BCOPY
|
||||
__SERVALDNA_OS_INLINE void bcopy(void *src, void *dst, size_t len) {
|
||||
memcpy(dst, src, len);
|
||||
}
|
||||
#endif
|
||||
|
||||
int mkdirs(const char *path, mode_t mode)
|
||||
{
|
||||
|
26
os.h
26
os.h
@ -17,13 +17,21 @@ along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __SERVALDNA_OS_H
|
||||
#define __SERVALDNA_OS_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifndef __SERVALDNA_OS_H
|
||||
#define __SERVALDNA_OS_H
|
||||
#ifndef __SERVALDNA_OS_INLINE
|
||||
# if __GNUC__ && !__GNUC_STDC_INLINE__
|
||||
# define __SERVALDNA_OS_INLINE extern inline
|
||||
# else
|
||||
# define __SERVALDNA_OS_INLINE inline
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* All wall clock times in the Serval daemon are represented in milliseconds
|
||||
* since the Unix epoch. The gettime_ms() function uses gettimeofday(2) to
|
||||
@ -49,11 +57,17 @@ typedef long long time_ms_t;
|
||||
time_ms_t gettime_ms();
|
||||
time_ms_t sleep_ms(time_ms_t milliseconds);
|
||||
|
||||
/* bzero(3) is deprecated in favour of memset(3). */
|
||||
#define bzero(addr,len) memset((addr), 0, (len))
|
||||
#ifndef HAVE_BZERO
|
||||
__SERVALDNA_OS_INLINE void bzero(void *buf, size_t len) {
|
||||
memset(buf, 0, len);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* OpenWRT libc doesn't have bcopy, but has memmove */
|
||||
#define bcopy(A,B,C) memmove(B,A,C)
|
||||
#ifndef HAVE_BCOPY
|
||||
__SERVALDNA_OS_INLINE void bcopy(void *src, void *dst, size_t len) {
|
||||
memcpy(dst, src, len);
|
||||
}
|
||||
#endif
|
||||
|
||||
int mkdirs(const char *path, mode_t mode);
|
||||
int mkdirsn(const char *path, size_t len, mode_t mode);
|
||||
|
Loading…
x
Reference in New Issue
Block a user