Commit be63a940 authored by Anton Blanchard's avatar Anton Blanchard

[PATCH] Fix ppc64 build problem

From: Paul Mackerras <paulus@samba.org>

Recent changes in include/linux/*.h meant that likely()
isn't defined here (since we don't set __KERNEL__), and thus
we don't get some prototypes and we can't use do_div.  This
fixes the resulting compile errors and warnings.

Remove %L handling from sprintf - we don't need it, and it
meant we needed do_div from asm/div64.h, which gives problems
when __KERNEL__ isn't defined.  Also add a prototype for
strlen to kill a warning.
parent d1c0dfc8
...@@ -11,9 +11,6 @@ ...@@ -11,9 +11,6 @@
#include <linux/string.h> #include <linux/string.h>
#include <linux/ctype.h> #include <linux/ctype.h>
#define BITS_PER_LONG 32
#include <asm/div64.h>
int (*prom)(void *); int (*prom)(void *);
void *chosen_handle; void *chosen_handle;
...@@ -28,6 +25,9 @@ void chrpboot(int a1, int a2, void *prom); /* in main.c */ ...@@ -28,6 +25,9 @@ void chrpboot(int a1, int a2, void *prom); /* in main.c */
void printk(char *fmt, ...); void printk(char *fmt, ...);
/* there is no convenient header to get this from... -- paulus */
extern unsigned long strlen(const char *);
int int
write(void *handle, void *ptr, int nb) write(void *handle, void *ptr, int nb)
{ {
...@@ -352,7 +352,7 @@ static int skip_atoi(const char **s) ...@@ -352,7 +352,7 @@ static int skip_atoi(const char **s)
#define SPECIAL 32 /* 0x */ #define SPECIAL 32 /* 0x */
#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */ #define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */
static char * number(char * str, long long num, int base, int size, int precision, int type) static char * number(char * str, long num, int base, int size, int precision, int type)
{ {
char c,sign,tmp[66]; char c,sign,tmp[66];
const char *digits="0123456789abcdefghijklmnopqrstuvwxyz"; const char *digits="0123456789abcdefghijklmnopqrstuvwxyz";
...@@ -388,8 +388,10 @@ static char * number(char * str, long long num, int base, int size, int precisio ...@@ -388,8 +388,10 @@ static char * number(char * str, long long num, int base, int size, int precisio
i = 0; i = 0;
if (num == 0) if (num == 0)
tmp[i++]='0'; tmp[i++]='0';
else while (num != 0) else while (num != 0) {
tmp[i++] = digits[do_div(num,base)]; tmp[i++] = digits[num % base];
num /= base;
}
if (i > precision) if (i > precision)
precision = i; precision = i;
size -= precision; size -= precision;
...@@ -424,7 +426,7 @@ int sprintf(char * buf, const char *fmt, ...); ...@@ -424,7 +426,7 @@ int sprintf(char * buf, const char *fmt, ...);
int vsprintf(char *buf, const char *fmt, va_list args) int vsprintf(char *buf, const char *fmt, va_list args)
{ {
int len; int len;
unsigned long long num; unsigned long num;
int i, base; int i, base;
char * str; char * str;
const char *s; const char *s;
...@@ -575,9 +577,7 @@ int vsprintf(char *buf, const char *fmt, va_list args) ...@@ -575,9 +577,7 @@ int vsprintf(char *buf, const char *fmt, va_list args)
--fmt; --fmt;
continue; continue;
} }
if (qualifier == 'L') if (qualifier == 'l') {
num = va_arg(args, long long);
else if (qualifier == 'l') {
num = va_arg(args, unsigned long); num = va_arg(args, unsigned long);
if (flags & SIGN) if (flags & SIGN)
num = (signed long) num; num = (signed long) num;
......
...@@ -102,9 +102,8 @@ extern char *z_errmsg[]; /* indexed by 1-zlib_error */ ...@@ -102,9 +102,8 @@ extern char *z_errmsg[]; /* indexed by 1-zlib_error */
/* functions */ /* functions */
#include <linux/string.h> extern void *memcpy(void *, const void *, unsigned long);
#define zmemcpy memcpy #define zmemcpy memcpy
#define zmemzero(dest, len) memset(dest, 0, len)
/* Diagnostic functions */ /* Diagnostic functions */
#ifdef DEBUG_ZLIB #ifdef DEBUG_ZLIB
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment