summaryrefslogtreecommitdiffstats
path: root/freebsd/lib
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2013-11-06 09:35:05 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2013-11-11 10:08:06 +0100
commit0a57e1db23218393483a356c07868413a45caeeb (patch)
treea2d1dd67f5b05a52b1f79f571c690ebcf299d775 /freebsd/lib
parentChange license to BSD (diff)
downloadrtems-libbsd-0a57e1db23218393483a356c07868413a45caeeb.tar.bz2
Reduce divergence from FreeBSD sources
Diffstat (limited to 'freebsd/lib')
-rw-r--r--freebsd/lib/libc/net/gethostbydns.c26
-rw-r--r--freebsd/lib/libc/net/gethostbyht.c13
-rw-r--r--freebsd/lib/libc/net/gethostnamadr.c4
-rw-r--r--freebsd/lib/libc/net/nsdispatch.c6
-rw-r--r--freebsd/lib/libc/net/res_config.h3
-rw-r--r--freebsd/lib/libc/stdio/fgetln.c3
-rw-r--r--freebsd/lib/libipsec/policy_token.l4
-rw-r--r--freebsd/lib/libmemstat/memstat_all.c2
-rw-r--r--freebsd/lib/libmemstat/memstat_malloc.c2
-rw-r--r--freebsd/lib/libmemstat/memstat_uma.c2
10 files changed, 21 insertions, 44 deletions
diff --git a/freebsd/lib/libc/net/gethostbydns.c b/freebsd/lib/libc/net/gethostbydns.c
index dce98b14..d1c62590 100644
--- a/freebsd/lib/libc/net/gethostbydns.c
+++ b/freebsd/lib/libc/net/gethostbydns.c
@@ -90,7 +90,7 @@ static void addrsort(char **, int, res_state);
#endif
#ifdef DEBUG
-static void DPRINTF(char *, int, res_state) __printflike(1, 0);
+static void dprintf(char *, int, res_state) __printflike(1, 0);
#endif
#define MAXPACKET (64*1024)
@@ -109,7 +109,7 @@ int _dns_ttl_;
#ifdef DEBUG
static void
-DPRINTF(msg, num, res)
+dprintf(msg, num, res)
char *msg;
int num;
res_state res;
@@ -122,7 +122,7 @@ DPRINTF(msg, num, res)
}
}
#else
-# define DPRINTF(msg, num, res) /*nada*/
+# define dprintf(msg, num, res) /*nada*/
#endif
#define BOUNDED_INCR(x) \
@@ -340,7 +340,6 @@ gethostanswer(const querybuf *answer, int anslen, const char *qname, int qtype,
break;
#else
he->h_name = bp;
-#ifdef INET6
if (statp->options & RES_USE_INET6) {
n = strlen(bp) + 1; /* for the \0 */
if (n >= MAXHOSTNAMELEN) {
@@ -350,7 +349,6 @@ gethostanswer(const querybuf *answer, int anslen, const char *qname, int qtype,
bp += n;
_map_v4v6_hostent(he, &bp, ep);
}
-#endif
RES_SET_H_ERRNO(statp, NETDB_SUCCESS);
return (0);
#endif
@@ -377,13 +375,13 @@ gethostanswer(const querybuf *answer, int anslen, const char *qname, int qtype,
bp += sizeof(align) - ((u_long)bp % sizeof(align));
if (bp + n >= ep) {
- DPRINTF("size (%d) too big\n", n, statp);
+ dprintf("size (%d) too big\n", n, statp);
had_error++;
continue;
}
if (hap >= &hed->h_addr_ptrs[_MAXADDRS-1]) {
if (!toobig++)
- DPRINTF("Too many addresses (%d)\n",
+ dprintf("Too many addresses (%d)\n",
_MAXADDRS, statp);
cp += n;
continue;
@@ -397,7 +395,7 @@ gethostanswer(const querybuf *answer, int anslen, const char *qname, int qtype,
}
break;
default:
- DPRINTF("Impossible condition (type=%d)\n", type,
+ dprintf("Impossible condition (type=%d)\n", type,
statp);
RES_SET_H_ERRNO(statp, NO_RECOVERY);
return (-1);
@@ -426,10 +424,8 @@ gethostanswer(const querybuf *answer, int anslen, const char *qname, int qtype,
he->h_name = bp;
bp += n;
}
-#ifdef INET6
if (statp->options & RES_USE_INET6)
_map_v4v6_hostent(he, &bp, ep);
-#endif
RES_SET_H_ERRNO(statp, NETDB_SUCCESS);
return (0);
}
@@ -526,12 +522,12 @@ _dns_gethostbyname(void *rval, void *cb_data, va_list ap)
n = res_nsearch(statp, name, C_IN, type, buf->buf, sizeof(buf->buf));
if (n < 0) {
free(buf);
- DPRINTF("res_nsearch failed (%d)\n", n, statp);
+ dprintf("res_nsearch failed (%d)\n", n, statp);
*h_errnop = statp->res_h_errno;
return (NS_NOTFOUND);
} else if (n > sizeof(buf->buf)) {
free(buf);
- DPRINTF("static buffer is too small (%d)\n", n, statp);
+ dprintf("static buffer is too small (%d)\n", n, statp);
*h_errnop = statp->res_h_errno;
return (NS_UNAVAIL);
}
@@ -633,13 +629,13 @@ _dns_gethostbyaddr(void *rval, void *cb_data, va_list ap)
sizeof buf->buf);
if (n < 0) {
free(buf);
- DPRINTF("res_nquery failed (%d)\n", n, statp);
+ dprintf("res_nquery failed (%d)\n", n, statp);
*h_errnop = statp->res_h_errno;
return (NS_UNAVAIL);
}
if (n > sizeof buf->buf) {
free(buf);
- DPRINTF("static buffer is too small (%d)\n", n, statp);
+ dprintf("static buffer is too small (%d)\n", n, statp);
*h_errnop = statp->res_h_errno;
return (NS_UNAVAIL);
}
@@ -703,13 +699,11 @@ _dns_gethostbyaddr(void *rval, void *cb_data, va_list ap)
memcpy(hed->host_addr, uaddr, len);
hed->h_addr_ptrs[0] = (char *)hed->host_addr;
hed->h_addr_ptrs[1] = NULL;
-#ifdef INET6
if (af == AF_INET && (statp->options & RES_USE_INET6)) {
_map_v4v6_address((char*)hed->host_addr, (char*)hed->host_addr);
he.h_addrtype = AF_INET6;
he.h_length = NS_IN6ADDRSZ;
}
-#endif
if (__copy_hostent(&he, hptr, buffer, buflen) != 0) {
*errnop = errno;
RES_SET_H_ERRNO(statp, NETDB_INTERNAL);
diff --git a/freebsd/lib/libc/net/gethostbyht.c b/freebsd/lib/libc/net/gethostbyht.c
index 3814ae7d..f373fcbd 100644
--- a/freebsd/lib/libc/net/gethostbyht.c
+++ b/freebsd/lib/libc/net/gethostbyht.c
@@ -115,7 +115,6 @@ gethostent_p(struct hostent *he, struct hostent_data *hed, int mapped,
if (!(cp = strpbrk(p, " \t")))
goto again;
*cp++ = '\0';
-#ifdef INET6
if (inet_pton(AF_INET6, p, hed->host_addr) > 0) {
af = AF_INET6;
len = IN6ADDRSZ;
@@ -132,12 +131,6 @@ gethostent_p(struct hostent *he, struct hostent_data *hed, int mapped,
} else {
goto again;
}
-#else
- if (inet_pton(AF_INET, p, hed->host_addr) > 0) {
- af = AF_INET;
- len = INADDRSZ;
- }
-#endif
hed->h_addr_ptrs[0] = (char *)hed->host_addr;
hed->h_addr_ptrs[1] = NULL;
he->h_addr_list = hed->h_addr_ptrs;
@@ -200,10 +193,8 @@ gethostent_r(struct hostent *hptr, char *buffer, size_t buflen,
*h_errnop = statp->res_h_errno;
return (-1);
}
-#ifdef INET6
if (gethostent_p(&he, hed, statp->options & RES_USE_INET6, statp) != 0)
return (-1);
-#endif
if (__copy_hostent(&he, hptr, buffer, buflen) != 0) {
RES_SET_H_ERRNO(statp, NETDB_INTERNAL);
*h_errnop = statp->res_h_errno;
@@ -263,14 +254,12 @@ _ht_gethostbyname(void *rval, void *cb_data, va_list ap)
while ((error = gethostent_p(&he, hed, 0, statp)) == 0) {
if (he.h_addrtype != af)
continue;
-#ifdef INET6
if (he.h_addrtype == AF_INET &&
statp->options & RES_USE_INET6) {
_map_v4v6_address(he.h_addr, he.h_addr);
he.h_length = IN6ADDRSZ;
he.h_addrtype = AF_INET6;
}
-#endif
if (strcasecmp(he.h_name, name) == 0)
break;
for (cp = he.h_aliases; *cp != 0; cp++)
@@ -328,7 +317,6 @@ _ht_gethostbyaddr(void *rval, void *cb_data, va_list ap)
_sethosthtent(0, hed);
while ((error = gethostent_p(&he, hed, 0, statp)) == 0)
-#ifdef INET6
if (he.h_addrtype == af && !bcmp(he.h_addr, addr, len)) {
if (he.h_addrtype == AF_INET &&
statp->options & RES_USE_INET6) {
@@ -338,7 +326,6 @@ _ht_gethostbyaddr(void *rval, void *cb_data, va_list ap)
}
break;
}
-#endif
_endhosthtent(hed);
if (error != 0)
diff --git a/freebsd/lib/libc/net/gethostnamadr.c b/freebsd/lib/libc/net/gethostnamadr.c
index 5c158467..7960be7c 100644
--- a/freebsd/lib/libc/net/gethostnamadr.c
+++ b/freebsd/lib/libc/net/gethostnamadr.c
@@ -458,23 +458,19 @@ fakeaddr(const char *name, int af, struct hostent *hp, char *buf,
}
strncpy(hed->hostbuf, name, MAXDNAME);
hed->hostbuf[MAXDNAME] = '\0';
-#ifdef INET6
if (af == AF_INET && (statp->options & RES_USE_INET6) != 0U) {
_map_v4v6_address((char *)hed->host_addr,
(char *)hed->host_addr);
af = AF_INET6;
}
-#endif
he.h_addrtype = af;
switch(af) {
case AF_INET:
he.h_length = NS_INADDRSZ;
break;
-#ifdef INET6
case AF_INET6:
he.h_length = NS_IN6ADDRSZ;
break;
-#endif
default:
errno = EAFNOSUPPORT;
RES_SET_H_ERRNO(statp, NETDB_INTERNAL);
diff --git a/freebsd/lib/libc/net/nsdispatch.c b/freebsd/lib/libc/net/nsdispatch.c
index 621ecad3..8caafdcc 100644
--- a/freebsd/lib/libc/net/nsdispatch.c
+++ b/freebsd/lib/libc/net/nsdispatch.c
@@ -519,13 +519,13 @@ nss_load_module(const char *source, nss_module_register_fn reg_fn)
goto fin;
}
}
-#endif
+#endif /* __rtems__ */
mod.mtab = fn(mod.name, &mod.mtabsize, &mod.unregister);
if (mod.mtab == NULL || mod.mtabsize == 0) {
#ifndef __rtems__
if (mod.handle != nss_builtin_handle)
(void)dlclose(mod.handle);
-#endif
+#endif /* __rtems__ */
mod.handle = NULL;
nss_log(LOG_ERR, "%s, registration failed", mod.name);
goto fin;
@@ -552,7 +552,7 @@ ns_mod_free(ns_mod *mod)
#ifndef __rtems__
if (mod->handle != nss_builtin_handle)
(void)dlclose(mod->handle);
-#endif
+#endif /* __rtems__ */
}
diff --git a/freebsd/lib/libc/net/res_config.h b/freebsd/lib/libc/net/res_config.h
index 05909bca..411542d1 100644
--- a/freebsd/lib/libc/net/res_config.h
+++ b/freebsd/lib/libc/net/res_config.h
@@ -4,3 +4,6 @@
#define RESOLVSORT /* allow sorting of addresses in gethostbyname */
#undef SUNSECURITY /* verify gethostbyaddr() calls - WE DONT NEED IT */
#define MULTI_PTRS_ARE_ALIASES 1 /* fold multiple PTR records into aliases */
+#ifdef __rtems__
+#define dprintf gethostbydns_dprintf
+#endif /* __rtems__ */
diff --git a/freebsd/lib/libc/stdio/fgetln.c b/freebsd/lib/libc/stdio/fgetln.c
index d27a7c4e..1a7b0514 100644
--- a/freebsd/lib/libc/stdio/fgetln.c
+++ b/freebsd/lib/libc/stdio/fgetln.c
@@ -106,9 +106,8 @@ fgetln(FILE *fp, size_t *lenp)
ret = (char *)fp->_p;
*lenp = len = p - fp->_p;
#ifndef __rtems__
-
fp->_flags |= __SMOD;
-#endif
+#endif /* __rtems__ */
fp->_r -= len;
fp->_p = p;
FUNLOCKFILE(fp);
diff --git a/freebsd/lib/libipsec/policy_token.l b/freebsd/lib/libipsec/policy_token.l
index d4167a4f..cc70ea90 100644
--- a/freebsd/lib/libipsec/policy_token.l
+++ b/freebsd/lib/libipsec/policy_token.l
@@ -49,10 +49,8 @@
#ifdef __rtems__
/* XXX - Jennifer doesn't know where to get this from */
static YY_BUFFER_STATE yy_current_buffer;
-#endif
-
+#endif /* __rtems__ */
#include "y.tab.h"
-
#define yylval __libipsecyylval /* XXX */
int yylex(void);
diff --git a/freebsd/lib/libmemstat/memstat_all.c b/freebsd/lib/libmemstat/memstat_all.c
index 4dc32666..c76a8528 100644
--- a/freebsd/lib/libmemstat/memstat_all.c
+++ b/freebsd/lib/libmemstat/memstat_all.c
@@ -59,4 +59,4 @@ memstat_kvm_all(struct memory_type_list *mtlp, void *kvm_handle)
return (-1);
return (0);
}
-#endif
+#endif /* __rtems__ */
diff --git a/freebsd/lib/libmemstat/memstat_malloc.c b/freebsd/lib/libmemstat/memstat_malloc.c
index 2d47b694..1f83de33 100644
--- a/freebsd/lib/libmemstat/memstat_malloc.c
+++ b/freebsd/lib/libmemstat/memstat_malloc.c
@@ -409,4 +409,4 @@ memstat_kvm_malloc(struct memory_type_list *list, void *kvm_handle)
return (0);
}
-#endif
+#endif /* __rtems__ */
diff --git a/freebsd/lib/libmemstat/memstat_uma.c b/freebsd/lib/libmemstat/memstat_uma.c
index 63153d82..127a7662 100644
--- a/freebsd/lib/libmemstat/memstat_uma.c
+++ b/freebsd/lib/libmemstat/memstat_uma.c
@@ -465,4 +465,4 @@ skip_percpu:
free(ucp_array);
return (0);
}
-#endif
+#endif /* __rtems__ */