Browse Source

Format changes to musl code to fit musl's style.

The whitespace diffs are converting from spaces to tabs.
pull/26/head
Dan Gohman 6 years ago
parent
commit
ec9f1c3956
  1. 8
      libc-top-half/musl/src/conf/sysconf.c
  2. 6
      libc-top-half/musl/src/internal/libm.h
  3. 14
      libc-top-half/musl/src/locale/newlocale.c
  4. 14
      libc-top-half/musl/src/misc/uname.c
  5. 2
      libc-top-half/musl/src/stdio/fopen.c
  6. 10
      libc-top-half/musl/src/stdio/freopen.c
  7. 2
      libc-top-half/musl/src/stdio/getc.h
  8. 2
      libc-top-half/musl/src/stdio/putc.h
  9. 2
      libc-top-half/musl/src/stdio/vfprintf.c
  10. 2
      libc-top-half/musl/src/stdio/vfwprintf.c
  11. 6
      libc-top-half/musl/src/stdlib/strtod.c

8
libc-top-half/musl/src/conf/sysconf.c

@ -33,7 +33,7 @@ long sysconf(int name)
#ifdef __wasilibc_unmodified_upstream // WASI has no processes #ifdef __wasilibc_unmodified_upstream // WASI has no processes
[_SC_CHILD_MAX] = RLIM(NPROC), [_SC_CHILD_MAX] = RLIM(NPROC),
#else #else
// Not supported on wasi. // Not supported on wasi.
[_SC_CHILD_MAX] = -1, [_SC_CHILD_MAX] = -1,
#endif #endif
[_SC_CLK_TCK] = 100, [_SC_CLK_TCK] = 100,
@ -76,7 +76,7 @@ long sysconf(int name)
#ifdef __wasilibc_unmodified_upstream // WASI has no realtime signals #ifdef __wasilibc_unmodified_upstream // WASI has no realtime signals
[_SC_RTSIG_MAX] = _NSIG - 1 - 31 - 3, [_SC_RTSIG_MAX] = _NSIG - 1 - 31 - 3,
#else #else
// Not supported on wasi. // Not supported on wasi.
[_SC_RTSIG_MAX] = -1, [_SC_RTSIG_MAX] = -1,
#endif #endif
#ifdef __wasilibc_unmodified_upstream // WASI has no semaphores #ifdef __wasilibc_unmodified_upstream // WASI has no semaphores
@ -220,7 +220,7 @@ long sysconf(int name)
return -1; return -1;
return lim.rlim_cur > LONG_MAX ? LONG_MAX : lim.rlim_cur; return lim.rlim_cur > LONG_MAX ? LONG_MAX : lim.rlim_cur;
#else #else
// Not supported on wasi. // Not supported on wasi.
errno = EINVAL; errno = EINVAL;
return -1; return -1;
#endif #endif
@ -253,7 +253,7 @@ long sysconf(int name)
for (; set[i]; set[i]&=set[i]-1, cnt++); for (; set[i]; set[i]&=set[i]-1, cnt++);
return cnt; return cnt;
#else #else
// With no thread support, just say there's 1 processor. // With no thread support, just say there's 1 processor.
return 1; return 1;
#endif #endif
#ifdef __wasilibc_unmodified_upstream // WASI has no sysinfo #ifdef __wasilibc_unmodified_upstream // WASI has no sysinfo

6
libc-top-half/musl/src/internal/libm.h

@ -85,10 +85,8 @@ union ldshape {
} \ } \
} while(0) } while(0)
#else #else
/* /* WebAssembly doesn't have floating-point status flags, so there's no reason
* WebAssembly doesn't have floating-point status flags, so there's no reason * to force evaluations. */
* to force evaluations.
* */
#define FORCE_EVAL(x) ((void)(x)) #define FORCE_EVAL(x) ((void)(x))
#endif #endif

14
libc-top-half/musl/src/locale/newlocale.c

@ -51,13 +51,13 @@ locale_t __newlocale(int mask, const char *name, locale_t loc)
* variant of the C locale honoring the default locale's encoding. */ * variant of the C locale honoring the default locale's encoding. */
pthread_once(&default_locale_once, default_locale_init); pthread_once(&default_locale_once, default_locale_init);
#else #else
{ {
static int called; static int called;
if (called == 0) { if (called == 0) {
default_locale_init(); default_locale_init();
called = 1; called = 1;
} }
} }
#endif #endif
if (!memcmp(&tmp, &default_locale, sizeof tmp)) return &default_locale; if (!memcmp(&tmp, &default_locale, sizeof tmp)) return &default_locale;
if (!memcmp(&tmp, &default_ctype_locale, sizeof tmp)) if (!memcmp(&tmp, &default_ctype_locale, sizeof tmp))

14
libc-top-half/musl/src/misc/uname.c

@ -10,23 +10,23 @@ int uname(struct utsname *uts)
#ifdef __wasilibc_unmodified_upstream // Implement uname with placeholders #ifdef __wasilibc_unmodified_upstream // Implement uname with placeholders
return syscall(SYS_uname, uts); return syscall(SYS_uname, uts);
#else #else
// Just fill in the fields with placeholder values. // Just fill in the fields with placeholder values.
strcpy(uts->sysname, "wasi"); strcpy(uts->sysname, "wasi");
strcpy(uts->nodename, "(none)"); strcpy(uts->nodename, "(none)");
strcpy(uts->release, "0.0.0"); strcpy(uts->release, "0.0.0");
strcpy(uts->version, "0.0.0"); strcpy(uts->version, "0.0.0");
#if defined(__wasm32__) #if defined(__wasm32__)
strcpy(uts->machine, "wasm32"); strcpy(uts->machine, "wasm32");
#elif defined(__wasm64__) #elif defined(__wasm64__)
strcpy(uts->machine, "wasm64"); strcpy(uts->machine, "wasm64");
#else #else
strcpy(uts->machine, "unknown"); strcpy(uts->machine, "unknown");
#endif #endif
#ifdef _GNU_SOURCE #ifdef _GNU_SOURCE
strcpy(uts->domainname, "(none)"); strcpy(uts->domainname, "(none)");
#else #else
strcpy(uts->__domainname, "(none)"); strcpy(uts->__domainname, "(none)");
#endif #endif
return 0; return 0;
#endif #endif
} }

2
libc-top-half/musl/src/stdio/fopen.c

@ -41,7 +41,7 @@ FILE *fopen(const char *restrict filename, const char *restrict mode)
#ifdef __wasilibc_unmodified_upstream // WASI has no syscall #ifdef __wasilibc_unmodified_upstream // WASI has no syscall
__syscall(SYS_close, fd); __syscall(SYS_close, fd);
#else #else
close(fd); close(fd);
#endif #endif
return 0; return 0;
} }

10
libc-top-half/musl/src/stdio/freopen.c

@ -50,12 +50,12 @@ FILE *freopen(const char *restrict filename, const char *restrict mode, FILE *re
#ifdef __wasilibc_unmodified_upstream // WASI has no dup #ifdef __wasilibc_unmodified_upstream // WASI has no dup
else if (__dup3(f2->fd, f->fd, fl&O_CLOEXEC)<0) goto fail2; else if (__dup3(f2->fd, f->fd, fl&O_CLOEXEC)<0) goto fail2;
#else #else
// WASI doesn't have dup3, but does have a way to renumber // WASI doesn't have dup3, but does have a way to renumber
// an existing file descriptor. // an existing file descriptor.
else { else {
if (__wasilibc_fd_renumber(f2->fd, f->fd)<0) goto fail2; if (__wasilibc_fd_renumber(f2->fd, f->fd)<0) goto fail2;
f2->fd = -1; /* avoid closing in fclose */ f2->fd = -1; /* avoid closing in fclose */
} }
#endif #endif
f->flags = (f->flags & F_PERM) | f2->flags; f->flags = (f->flags & F_PERM) | f2->flags;

2
libc-top-half/musl/src/stdio/getc.h

@ -23,7 +23,7 @@ static inline int do_getc(FILE *f)
return getc_unlocked(f); return getc_unlocked(f);
return locking_getc(f); return locking_getc(f);
#else #else
// With no threads, locking is unnecessary. // With no threads, locking is unnecessary.
return getc_unlocked(f); return getc_unlocked(f);
#endif #endif
} }

2
libc-top-half/musl/src/stdio/putc.h

@ -23,7 +23,7 @@ static inline int do_putc(int c, FILE *f)
return putc_unlocked(c, f); return putc_unlocked(c, f);
return locking_putc(c, f); return locking_putc(c, f);
#else #else
// With no threads, locking is unnecessary. // With no threads, locking is unnecessary.
return putc_unlocked(c, f); return putc_unlocked(c, f);
#endif #endif
} }

2
libc-top-half/musl/src/stdio/vfprintf.c

@ -138,7 +138,7 @@ static void pop_arg(union arg *arg, int type, va_list *ap)
#if defined(__wasilibc_printscan_no_floating_point) #if defined(__wasilibc_printscan_no_floating_point)
break; case DBL: break; case DBL:
case LDBL: case LDBL:
floating_point_not_supported(); floating_point_not_supported();
#else #else
break; case DBL: arg->f = va_arg(*ap, double); break; case DBL: arg->f = va_arg(*ap, double);
#if defined(__wasilibc_printscan_no_long_double) #if defined(__wasilibc_printscan_no_long_double)

2
libc-top-half/musl/src/stdio/vfwprintf.c

@ -320,7 +320,7 @@ static int wprintf_core(FILE *f, const wchar_t *fmt, va_list *ap, union arg *nl_
if (xp && p<0) goto overflow; if (xp && p<0) goto overflow;
#if defined(__wasilibc_printscan_no_long_double) #if defined(__wasilibc_printscan_no_long_double)
// Omit the 'L' modifier for floating-point cases. // Omit the 'L' modifier for floating-point cases.
switch (t|32) { switch (t|32) {
case 'a': case 'e': case 'f': case 'g': case 'a': case 'e': case 'f': case 'g':
snprintf(charfmt, sizeof charfmt, "%%%s%s%s%s%s*.*%c", snprintf(charfmt, sizeof charfmt, "%%%s%s%s%s%s*.*%c",

6
libc-top-half/musl/src/stdlib/strtod.c

@ -58,12 +58,12 @@ weak_alias(strtold, __strtold_l);
// WebAssembly doesn't permit signature-changing aliases, so use wrapper // WebAssembly doesn't permit signature-changing aliases, so use wrapper
// functions instead. // functions instead.
weak float strtof_l(const char *restrict s, char **restrict p, locale_t loc) { weak float strtof_l(const char *restrict s, char **restrict p, locale_t loc) {
return strtof(s, p); return strtof(s, p);
} }
weak double strtod_l(const char *restrict s, char **restrict p, locale_t loc) { weak double strtod_l(const char *restrict s, char **restrict p, locale_t loc) {
return strtod(s, p); return strtod(s, p);
} }
weak long double strtold_l(const char *restrict s, char **restrict p, locale_t loc) { weak long double strtold_l(const char *restrict s, char **restrict p, locale_t loc) {
return strtold(s, p); return strtold(s, p);
} }
#endif #endif

Loading…
Cancel
Save