Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete several blocks of unused code. #294

Merged
merged 2 commits into from
Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions expected/wasm32-wasi/defined-symbols.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
_CLOCK_MONOTONIC
_CLOCK_PROCESS_CPUTIME_ID
_CLOCK_REALTIME
_CLOCK_THREAD_CPUTIME_ID
_Exit
_IO_feof_unlocked
_IO_ferror_unlocked
Expand Down
2 changes: 0 additions & 2 deletions expected/wasm32-wasi/predefined-macros.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@
#define CLNEXT CTRL('v')
#define CLOCKS_PER_SEC ((clock_t)1000000000)
#define CLOCK_MONOTONIC (&_CLOCK_MONOTONIC)
#define CLOCK_PROCESS_CPUTIME_ID (&_CLOCK_PROCESS_CPUTIME_ID)
#define CLOCK_REALTIME (&_CLOCK_REALTIME)
#define CLOCK_THREAD_CPUTIME_ID (&_CLOCK_THREAD_CPUTIME_ID)
#define CMIN 1
#define CMPLX(x,y) __CMPLX(x, y, double)
#define CMPLXF(x,y) __CMPLX(x, y, float)
Expand Down
22 changes: 0 additions & 22 deletions libc-bottom-half/cloudlibc/src/common/errno.h

This file was deleted.

15 changes: 0 additions & 15 deletions libc-bottom-half/cloudlibc/src/common/overflow.h

This file was deleted.

46 changes: 4 additions & 42 deletions libc-bottom-half/cloudlibc/src/common/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#define COMMON_TIME_H

#include <common/limits.h>
#include <common/overflow.h>

#include <sys/time.h>

Expand All @@ -16,43 +15,6 @@

#define NSEC_PER_SEC 1000000000

// Timezone agnostic conversion routines.
int __localtime_utc(time_t, struct tm *);
void __mktime_utc(const struct tm *, struct timespec *);

static inline bool is_leap(time_t year) {
year %= 400;
if (year < 0)
year += 400;
return ((year % 4) == 0 && (year % 100) != 0) || year == 100;
}

// Gets the length of the months in a year.
static inline const char *get_months(time_t year) {
static const char leap[12] = {
31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
};
static const char common[12] = {
31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
};
return is_leap(year) ? leap : common;
}

// Gets the cumulative length of the months in a year.
static inline const short *get_months_cumulative(time_t year) {
static const short leap[13] = {
0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366,
};
static const short common[13] = {
0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365,
};
return is_leap(year) ? leap : common;
}

static inline short get_ydays(time_t year) {
return is_leap(year) ? 366 : 365;
}

static inline bool timespec_to_timestamp_exact(
const struct timespec *timespec, __wasi_timestamp_t *timestamp) {
// Invalid nanoseconds field.
Expand All @@ -64,8 +26,8 @@ static inline bool timespec_to_timestamp_exact(
return false;

// Make sure our timestamp does not overflow.
return !mul_overflow(timespec->tv_sec, NSEC_PER_SEC, timestamp) &&
!add_overflow(*timestamp, timespec->tv_nsec, timestamp);
return !__builtin_mul_overflow(timespec->tv_sec, NSEC_PER_SEC, timestamp) &&
!__builtin_add_overflow(*timestamp, timespec->tv_nsec, timestamp);
}

static inline bool timespec_to_timestamp_clamp(
Expand All @@ -77,8 +39,8 @@ static inline bool timespec_to_timestamp_clamp(
if (timespec->tv_sec < 0) {
// Timestamps before the Epoch are not supported.
*timestamp = 0;
} else if (mul_overflow(timespec->tv_sec, NSEC_PER_SEC, timestamp) ||
add_overflow(*timestamp, timespec->tv_nsec, timestamp)) {
} else if (__builtin_mul_overflow(timespec->tv_sec, NSEC_PER_SEC, timestamp) ||
__builtin_add_overflow(*timestamp, timespec->tv_nsec, timestamp)) {
// Make sure our timestamp does not overflow.
*timestamp = NUMERIC_MAX(__wasi_timestamp_t);
}
Expand Down
113 changes: 0 additions & 113 deletions libc-bottom-half/cloudlibc/src/include/_/cdefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,126 +24,13 @@
#ifndef ___CDEFS_H_
#define ___CDEFS_H_

// Version information.
#define __cloudlibc__ 1
#define __cloudlibc_major__ 0
#define __cloudlibc_minor__ 102

#ifdef __cplusplus
#define __BEGIN_DECLS extern "C" {
#define __END_DECLS }
#else
#define __BEGIN_DECLS
#define __END_DECLS
#endif

// Whether we should provide inline versions of functions. Due to C++'s
// support for namespaces, it is generally a bad idea to declare
// function macros.
#ifdef __cplusplus
#define _CLOUDLIBC_INLINE_FUNCTIONS 0
#else
#define _CLOUDLIBC_INLINE_FUNCTIONS 1
#endif

// Compiler-independent annotations.

#ifndef __has_builtin
#define __has_builtin(x) 0
#endif
#ifndef __has_extension
#define __has_extension(x) __has_feature(x)
#endif
#ifndef __has_feature
#define __has_feature(x) 0
#endif

#define __offsetof(type, member) __builtin_offsetof(type, member)
#define __containerof(ptr, type, member) \
((type *)((char *)(ptr)-__offsetof(type, member)))

#define __extname(x) __asm__(x)
#define __malloc_like __attribute__((__malloc__))
#define __pure2 __attribute__((__const__))
#define __pure __attribute__((__pure__))
#define __section(x) __attribute__((__section__(x)))
#define __unused __attribute__((__unused__))
#define __used __attribute__((__used__))
#define __weak_symbol __attribute__((__weak__))

// Format string argument type checking.
#define __printflike(format, va) \
__attribute__((__format__(__printf__, format, va)))
#define __scanflike(format, va) \
__attribute__((__format__(__scanf__, format, va)))
// TODO(ed): Enable this once supported by LLVM:
// https://llvm.org/bugs/show_bug.cgi?id=16810
#define __wprintflike(format, va)
#define __wscanflike(format, va)

#define __strong_reference(oldsym, newsym) \
extern __typeof__(oldsym) newsym __attribute__((__alias__(#oldsym)))

// Convenience macros.

#define __arraycount(x) (sizeof(x) / sizeof((x)[0]))
#define __howmany(x, y) (((x) + (y)-1) / (y))
#define __rounddown(x, y) (((x) / (y)) * (y))
#define __roundup(x, y) ((((x) + (y)-1) / (y)) * (y))

// Lock annotations.

#if __has_extension(c_thread_safety_attributes)
#define __lock_annotate(x) __attribute__((x))
#else
#define __lock_annotate(x)
#endif

#define __lockable __lock_annotate(lockable)

#define __locks_exclusive(...) \
__lock_annotate(exclusive_lock_function(__VA_ARGS__))
#define __locks_shared(...) __lock_annotate(shared_lock_function(__VA_ARGS__))

#define __trylocks_exclusive(...) \
__lock_annotate(exclusive_trylock_function(__VA_ARGS__))
#define __trylocks_shared(...) \
__lock_annotate(shared_trylock_function(__VA_ARGS__))

#define __unlocks(...) __lock_annotate(unlock_function(__VA_ARGS__))

#define __asserts_exclusive(...) \
__lock_annotate(assert_exclusive_lock(__VA_ARGS__))
#define __asserts_shared(...) __lock_annotate(assert_shared_lock(__VA_ARGS__))

#define __requires_exclusive(...) \
__lock_annotate(exclusive_locks_required(__VA_ARGS__))
#define __requires_shared(...) \
__lock_annotate(shared_locks_required(__VA_ARGS__))
#define __requires_unlocked(...) __lock_annotate(locks_excluded(__VA_ARGS__))

#define __no_lock_analysis __lock_annotate(no_thread_safety_analysis)

#define __guarded_by(x) __lock_annotate(guarded_by(x))
#define __pt_guarded_by(x) __lock_annotate(pt_guarded_by(x))

// Const preservation.
//
// Functions like strchr() allow you to silently discard a const
// qualifier from a string. This macro can be used to wrap such
// functions to propagate the const keyword where possible.
//
// This macro has many limitations, such as only being able to detect
// constness for void, char and wchar_t. For Clang, it also doesn't seem
// to work on string literals.

#define __preserve_const(type, name, arg, ...) \
_Generic(arg, \
const void *: (const type *)name(__VA_ARGS__), \
const char *: (const type *)name(__VA_ARGS__), \
const signed char *: (const type *)name(__VA_ARGS__), \
const unsigned char *: (const type *)name(__VA_ARGS__), \
const __wchar_t *: (const type *)name(__VA_ARGS__), \
default: name(__VA_ARGS__))

#endif
Loading