forked from KolibriOS/kolibrios
ddk: 4.4
git-svn-id: svn://kolibrios.org@6082 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
@@ -17,15 +17,15 @@
|
||||
#define USHRT_MAX ((u16)(~0U))
|
||||
#define SHRT_MAX ((s16)(USHRT_MAX>>1))
|
||||
#define SHRT_MIN ((s16)(-SHRT_MAX - 1))
|
||||
#define INT_MAX ((int)(~0U>>1))
|
||||
#define INT_MIN (-INT_MAX - 1)
|
||||
#define UINT_MAX (~0U)
|
||||
#define LONG_MAX ((long)(~0UL>>1))
|
||||
#define LONG_MIN (-LONG_MAX - 1)
|
||||
#define ULONG_MAX (~0UL)
|
||||
#define LLONG_MAX ((long long)(~0ULL>>1))
|
||||
#define LLONG_MIN (-LLONG_MAX - 1)
|
||||
#define ULLONG_MAX (~0ULL)
|
||||
#define INT_MAX ((int)(~0U>>1))
|
||||
#define INT_MIN (-INT_MAX - 1)
|
||||
#define UINT_MAX (~0U)
|
||||
#define LONG_MAX ((long)(~0UL>>1))
|
||||
#define LONG_MIN (-LONG_MAX - 1)
|
||||
#define ULONG_MAX (~0UL)
|
||||
#define LLONG_MAX ((long long)(~0ULL>>1))
|
||||
#define LLONG_MIN (-LLONG_MAX - 1)
|
||||
#define ULLONG_MAX (~0ULL)
|
||||
#define SIZE_MAX (~(size_t)0)
|
||||
|
||||
#define U8_MAX ((u8)~0U)
|
||||
@@ -47,8 +47,8 @@
|
||||
|
||||
#define ALIGN(x, a) __ALIGN_KERNEL((x), (a))
|
||||
#define __ALIGN_MASK(x, mask) __ALIGN_KERNEL_MASK((x), (mask))
|
||||
#define PTR_ALIGN(p, a) ((typeof(p))ALIGN((unsigned long)(p), (a)))
|
||||
#define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0)
|
||||
#define PTR_ALIGN(p, a) ((typeof(p))ALIGN((unsigned long)(p), (a)))
|
||||
#define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0)
|
||||
|
||||
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
|
||||
|
||||
@@ -74,11 +74,11 @@
|
||||
#endif
|
||||
|
||||
/* The `const' in roundup() prevents gcc-3.3 from calling __divdi3 */
|
||||
#define roundup(x, y) ( \
|
||||
{ \
|
||||
const typeof(y) __y = y; \
|
||||
(((x) + (__y - 1)) / __y) * __y; \
|
||||
} \
|
||||
#define roundup(x, y) ( \
|
||||
{ \
|
||||
const typeof(y) __y = y; \
|
||||
(((x) + (__y - 1)) / __y) * __y; \
|
||||
} \
|
||||
)
|
||||
#define rounddown(x, y) ( \
|
||||
{ \
|
||||
@@ -92,15 +92,27 @@
|
||||
* to closest integer. Result is undefined for negative divisors and
|
||||
* for negative dividends if the divisor variable type is unsigned.
|
||||
*/
|
||||
#define DIV_ROUND_CLOSEST(x, divisor)( \
|
||||
{ \
|
||||
#define DIV_ROUND_CLOSEST(x, divisor)( \
|
||||
{ \
|
||||
typeof(x) __x = x; \
|
||||
typeof(divisor) __d = divisor; \
|
||||
(((typeof(x))-1) > 0 || \
|
||||
((typeof(divisor))-1) > 0 || (__x) > 0) ? \
|
||||
(((__x) + ((__d) / 2)) / (__d)) : \
|
||||
(((__x) - ((__d) / 2)) / (__d)); \
|
||||
} \
|
||||
} \
|
||||
)
|
||||
/*
|
||||
* Same as above but for u64 dividends. divisor must be a 32-bit
|
||||
* number.
|
||||
*/
|
||||
#define DIV_ROUND_CLOSEST_ULL(x, divisor)( \
|
||||
{ \
|
||||
typeof(divisor) __d = divisor; \
|
||||
unsigned long long _tmp = (x) + (__d) / 2; \
|
||||
do_div(_tmp, __d); \
|
||||
_tmp; \
|
||||
} \
|
||||
)
|
||||
|
||||
/*
|
||||
@@ -149,29 +161,89 @@
|
||||
*/
|
||||
#define lower_32_bits(n) ((u32)(n))
|
||||
|
||||
#ifdef CONFIG_PREEMPT_VOLUNTARY
|
||||
extern int _cond_resched(void);
|
||||
# define might_resched() _cond_resched()
|
||||
#else
|
||||
# define might_resched() do { } while (0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* abs() handles unsigned and signed longs, ints, shorts and chars. For all
|
||||
* input types abs() returns a signed long.
|
||||
* abs() should not be used for 64-bit types (s64, u64, long long) - use abs64()
|
||||
* for those.
|
||||
#ifdef CONFIG_DEBUG_ATOMIC_SLEEP
|
||||
void ___might_sleep(const char *file, int line, int preempt_offset);
|
||||
void __might_sleep(const char *file, int line, int preempt_offset);
|
||||
/**
|
||||
* might_sleep - annotation for functions that can sleep
|
||||
*
|
||||
* this macro will print a stack trace if it is executed in an atomic
|
||||
* context (spinlock, irq-handler, ...).
|
||||
*
|
||||
* This is a useful debugging help to be able to catch problems early and not
|
||||
* be bitten later when the calling function happens to sleep when it is not
|
||||
* supposed to.
|
||||
*/
|
||||
#define abs(x) ({ \
|
||||
long ret; \
|
||||
if (sizeof(x) == sizeof(long)) { \
|
||||
long __x = (x); \
|
||||
ret = (__x < 0) ? -__x : __x; \
|
||||
} else { \
|
||||
int __x = (x); \
|
||||
ret = (__x < 0) ? -__x : __x; \
|
||||
} \
|
||||
ret; \
|
||||
})
|
||||
# define might_sleep() \
|
||||
do { __might_sleep(__FILE__, __LINE__, 0); might_resched(); } while (0)
|
||||
# define sched_annotate_sleep() (current->task_state_change = 0)
|
||||
#else
|
||||
static inline void ___might_sleep(const char *file, int line,
|
||||
int preempt_offset) { }
|
||||
static inline void __might_sleep(const char *file, int line,
|
||||
int preempt_offset) { }
|
||||
# define might_sleep() do { might_resched(); } while (0)
|
||||
# define sched_annotate_sleep() do { } while (0)
|
||||
#endif
|
||||
|
||||
#define abs64(x) ({ \
|
||||
s64 __x = (x); \
|
||||
(__x < 0) ? -__x : __x; \
|
||||
})
|
||||
#define might_sleep_if(cond) do { if (cond) might_sleep(); } while (0)
|
||||
|
||||
/**
|
||||
* abs - return absolute value of an argument
|
||||
* @x: the value. If it is unsigned type, it is converted to signed type first
|
||||
* (s64, long or int depending on its size).
|
||||
*
|
||||
* Return: an absolute value of x. If x is 64-bit, macro's return type is s64,
|
||||
* otherwise it is signed long.
|
||||
*/
|
||||
#define abs(x) __builtin_choose_expr(sizeof(x) == sizeof(s64), ({ \
|
||||
s64 __x = (x); \
|
||||
(__x < 0) ? -__x : __x; \
|
||||
}), ({ \
|
||||
long ret; \
|
||||
if (sizeof(x) == sizeof(long)) { \
|
||||
long __x = (x); \
|
||||
ret = (__x < 0) ? -__x : __x; \
|
||||
} else { \
|
||||
int __x = (x); \
|
||||
ret = (__x < 0) ? -__x : __x; \
|
||||
} \
|
||||
ret; \
|
||||
}))
|
||||
|
||||
/**
|
||||
* reciprocal_scale - "scale" a value into range [0, ep_ro)
|
||||
* @val: value
|
||||
* @ep_ro: right open interval endpoint
|
||||
*
|
||||
* Perform a "reciprocal multiplication" in order to "scale" a value into
|
||||
* range [0, ep_ro), where the upper interval endpoint is right-open.
|
||||
* This is useful, e.g. for accessing a index of an array containing
|
||||
* ep_ro elements, for example. Think of it as sort of modulus, only that
|
||||
* the result isn't that of modulo. ;) Note that if initial input is a
|
||||
* small value, then result will return 0.
|
||||
*
|
||||
* Return: a result based on val in interval [0, ep_ro).
|
||||
*/
|
||||
static inline u32 reciprocal_scale(u32 val, u32 ep_ro)
|
||||
{
|
||||
return (u32)(((u64) val * ep_ro) >> 32);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_MMU) && \
|
||||
(defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_DEBUG_ATOMIC_SLEEP))
|
||||
#define might_fault() __might_fault(__FILE__, __LINE__)
|
||||
void __might_fault(const char *file, int line);
|
||||
#else
|
||||
static inline void might_fault(void) { }
|
||||
#endif
|
||||
|
||||
#define KERN_EMERG "<0>" /* system is unusable */
|
||||
#define KERN_ALERT "<1>" /* action must be taken immediately */
|
||||
@@ -181,6 +253,15 @@
|
||||
#define KERN_NOTICE "<5>" /* normal but significant condition */
|
||||
#define KERN_INFO "<6>" /* informational */
|
||||
#define KERN_DEBUG "<7>" /* debug-level messages */
|
||||
extern unsigned long simple_strtoul(const char *,char **,unsigned int);
|
||||
extern long simple_strtol(const char *,char **,unsigned int);
|
||||
extern unsigned long long simple_strtoull(const char *,char **,unsigned int);
|
||||
extern long long simple_strtoll(const char *,char **,unsigned int);
|
||||
|
||||
extern int num_to_str(char *buf, int size, unsigned long long num);
|
||||
|
||||
/* lib/printf utilities */
|
||||
|
||||
extern __printf(2, 3) int sprintf(char *buf, const char * fmt, ...);
|
||||
extern __printf(2, 0) int vsprintf(char *buf, const char *, va_list);
|
||||
extern __printf(3, 4)
|
||||
@@ -193,7 +274,16 @@ extern __printf(3, 0)
|
||||
int vscnprintf(char *buf, size_t size, const char *fmt, va_list args);
|
||||
extern __printf(2, 3)
|
||||
char *kasprintf(gfp_t gfp, const char *fmt, ...);
|
||||
extern char *kvasprintf(gfp_t gfp, const char *fmt, va_list args);
|
||||
extern __printf(2, 0)
|
||||
char *kvasprintf(gfp_t gfp, const char *fmt, va_list args);
|
||||
extern __printf(2, 0)
|
||||
const char *kvasprintf_const(gfp_t gfp, const char *fmt, va_list args);
|
||||
|
||||
extern __scanf(2, 3)
|
||||
int sscanf(const char *, const char *, ...);
|
||||
extern __scanf(2, 0)
|
||||
int vsscanf(const char *, const char *, va_list);
|
||||
extern int oops_in_progress; /* If set, an oops, panic(), BUG() or die() is in progress */
|
||||
enum lockdep_ok {
|
||||
LOCKDEP_STILL_OK,
|
||||
LOCKDEP_NOW_UNRELIABLE
|
||||
@@ -229,6 +319,7 @@ extern enum system_states {
|
||||
#define TAINT_OOT_MODULE 12
|
||||
#define TAINT_UNSIGNED_MODULE 13
|
||||
#define TAINT_SOFTLOCKUP 14
|
||||
#define TAINT_LIVEPATCH 15
|
||||
|
||||
extern const char hex_asc[];
|
||||
#define hex_asc_lo(x) hex_asc[((x) & 0x0f)]
|
||||
@@ -277,12 +368,6 @@ bool mac_pton(const char *s, u8 *mac);
|
||||
*
|
||||
* Most likely, you want to use tracing_on/tracing_off.
|
||||
*/
|
||||
#ifdef CONFIG_RING_BUFFER
|
||||
/* trace_off_permanent stops recording with no way to bring it back */
|
||||
void tracing_off_permanent(void);
|
||||
#else
|
||||
static inline void tracing_off_permanent(void) { }
|
||||
#endif
|
||||
|
||||
enum ftrace_dump_mode {
|
||||
DUMP_NONE,
|
||||
@@ -426,10 +511,10 @@ do { \
|
||||
__ftrace_vprintk(_THIS_IP_, fmt, vargs); \
|
||||
} while (0)
|
||||
|
||||
extern int
|
||||
extern __printf(2, 0) int
|
||||
__ftrace_vbprintk(unsigned long ip, const char *fmt, va_list ap);
|
||||
|
||||
extern int
|
||||
extern __printf(2, 0) int
|
||||
__ftrace_vprintk(unsigned long ip, const char *fmt, va_list ap);
|
||||
|
||||
extern void ftrace_dump(enum ftrace_dump_mode oops_dump_mode);
|
||||
@@ -449,7 +534,7 @@ int trace_printk(const char *fmt, ...)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static inline int
|
||||
static __printf(1, 0) inline int
|
||||
ftrace_vprintk(const char *fmt, va_list ap)
|
||||
{
|
||||
return 0;
|
||||
@@ -462,17 +547,17 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
|
||||
* strict type-checking.. See the
|
||||
* "unnecessary" pointer comparison.
|
||||
*/
|
||||
#define min(x, y) ({ \
|
||||
typeof(x) _min1 = (x); \
|
||||
typeof(y) _min2 = (y); \
|
||||
(void) (&_min1 == &_min2); \
|
||||
_min1 < _min2 ? _min1 : _min2; })
|
||||
#define min(x, y) ({ \
|
||||
typeof(x) _min1 = (x); \
|
||||
typeof(y) _min2 = (y); \
|
||||
(void) (&_min1 == &_min2); \
|
||||
_min1 < _min2 ? _min1 : _min2; })
|
||||
|
||||
#define max(x, y) ({ \
|
||||
typeof(x) _max1 = (x); \
|
||||
typeof(y) _max2 = (y); \
|
||||
(void) (&_max1 == &_max2); \
|
||||
_max1 > _max2 ? _max1 : _max2; })
|
||||
#define max(x, y) ({ \
|
||||
typeof(x) _max1 = (x); \
|
||||
typeof(y) _max2 = (y); \
|
||||
(void) (&_max1 == &_max2); \
|
||||
_max1 > _max2 ? _max1 : _max2; })
|
||||
|
||||
#define min3(x, y, z) min((typeof(x))min(x, y), z)
|
||||
#define max3(x, y, z) max((typeof(x))max(x, y), z)
|
||||
@@ -504,15 +589,15 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
|
||||
*
|
||||
* Or not use min/max/clamp at all, of course.
|
||||
*/
|
||||
#define min_t(type, x, y) ({ \
|
||||
type __min1 = (x); \
|
||||
type __min2 = (y); \
|
||||
__min1 < __min2 ? __min1: __min2; })
|
||||
#define min_t(type, x, y) ({ \
|
||||
type __min1 = (x); \
|
||||
type __min2 = (y); \
|
||||
__min1 < __min2 ? __min1: __min2; })
|
||||
|
||||
#define max_t(type, x, y) ({ \
|
||||
type __max1 = (x); \
|
||||
type __max2 = (y); \
|
||||
__max1 > __max2 ? __max1: __max2; })
|
||||
#define max_t(type, x, y) ({ \
|
||||
type __max1 = (x); \
|
||||
type __max2 = (y); \
|
||||
__max1 > __max2 ? __max1: __max2; })
|
||||
|
||||
/**
|
||||
* clamp_t - return a value clamped to a given range using a given type
|
||||
@@ -548,14 +633,14 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
|
||||
|
||||
/**
|
||||
* container_of - cast a member of a structure out to the containing structure
|
||||
* @ptr: the pointer to the member.
|
||||
* @type: the type of the container struct this is embedded in.
|
||||
* @member: the name of the member within the struct.
|
||||
* @ptr: the pointer to the member.
|
||||
* @type: the type of the container struct this is embedded in.
|
||||
* @member: the name of the member within the struct.
|
||||
*
|
||||
*/
|
||||
#define container_of(ptr, type, member) ({ \
|
||||
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
|
||||
(type *)( (char *)__mptr - offsetof(type,member) );})
|
||||
#define container_of(ptr, type, member) ({ \
|
||||
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
|
||||
(type *)( (char *)__mptr - offsetof(type,member) );})
|
||||
|
||||
/* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */
|
||||
#ifdef CONFIG_FTRACE_MCOUNT_RECORD
|
||||
@@ -563,14 +648,16 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
|
||||
#endif
|
||||
|
||||
/* Permissions on a sysfs file: you didn't miss the 0 prefix did you? */
|
||||
#define VERIFY_OCTAL_PERMISSIONS(perms) \
|
||||
(BUILD_BUG_ON_ZERO((perms) < 0) + \
|
||||
BUILD_BUG_ON_ZERO((perms) > 0777) + \
|
||||
/* User perms >= group perms >= other perms */ \
|
||||
BUILD_BUG_ON_ZERO(((perms) >> 6) < (((perms) >> 3) & 7)) + \
|
||||
BUILD_BUG_ON_ZERO((((perms) >> 3) & 7) < ((perms) & 7)) + \
|
||||
/* Other writable? Generally considered a bad idea. */ \
|
||||
BUILD_BUG_ON_ZERO((perms) & 2) + \
|
||||
#define VERIFY_OCTAL_PERMISSIONS(perms) \
|
||||
(BUILD_BUG_ON_ZERO((perms) < 0) + \
|
||||
BUILD_BUG_ON_ZERO((perms) > 0777) + \
|
||||
/* USER_READABLE >= GROUP_READABLE >= OTHER_READABLE */ \
|
||||
BUILD_BUG_ON_ZERO((((perms) >> 6) & 4) < (((perms) >> 3) & 4)) + \
|
||||
BUILD_BUG_ON_ZERO((((perms) >> 3) & 4) < ((perms) & 4)) + \
|
||||
/* USER_WRITABLE >= GROUP_WRITABLE */ \
|
||||
BUILD_BUG_ON_ZERO((((perms) >> 6) & 2) < (((perms) >> 3) & 2)) + \
|
||||
/* OTHER_WRITABLE? Generally considered a bad idea. */ \
|
||||
BUILD_BUG_ON_ZERO((perms) & 2) + \
|
||||
(perms))
|
||||
|
||||
|
||||
@@ -591,22 +678,6 @@ struct file
|
||||
struct vm_area_struct {};
|
||||
struct address_space {};
|
||||
|
||||
struct device
|
||||
{
|
||||
struct device *parent;
|
||||
void *driver_data;
|
||||
};
|
||||
|
||||
static inline void dev_set_drvdata(struct device *dev, void *data)
|
||||
{
|
||||
dev->driver_data = data;
|
||||
}
|
||||
|
||||
static inline void *dev_get_drvdata(struct device *dev)
|
||||
{
|
||||
return dev->driver_data;
|
||||
}
|
||||
|
||||
|
||||
#define in_dbg_master() (0)
|
||||
|
||||
@@ -728,9 +799,6 @@ struct pagelist {
|
||||
#define IS_ENABLED(a) 0
|
||||
|
||||
|
||||
#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
|
||||
|
||||
|
||||
|
||||
#define cpufreq_quick_get_max(x) GetCpuFreq()
|
||||
|
||||
@@ -771,8 +839,6 @@ static inline __must_check long __copy_to_user(void __user *to,
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct seq_file;
|
||||
|
||||
void *kmap(struct page *page);
|
||||
void *kmap_atomic(struct page *page);
|
||||
void kunmap(struct page *page);
|
||||
@@ -787,5 +853,4 @@ typedef u64 async_cookie_t;
|
||||
|
||||
#define CONFIG_PAGE_OFFSET 0
|
||||
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user