Permalink
Browse files

Add usleep to newlib, silence some warnings

  • Loading branch information...
klange committed Mar 27, 2013
1 parent 5867eec commit 4fc6fe741a20e9cbbe0fdb957f0c2b695354c57d
@@ -86,17 +86,16 @@ int _exit(int val){
return syscall_exit(val);
}
-int execve(char *name, char **argv, char **env) {
- return syscall_execve(name,argv,env);
+int execve(const char *name, char * const argv[], char * const envp[]) {
+ return syscall_execve((char*)name,(char**)argv,(char**)envp);
}
int execvp(const char *file, char *const argv[]) {
- return syscall_execve(file,argv,environ);
+ return execve(file,argv,environ);
}
int execv(const char * file, char *const argv[]) {
- DEBUG_STUB("execv(%s,...);\n", file);
- return syscall_execve(file,argv,environ);
+ return execve(file,argv,environ);
}
/*
@@ -223,31 +222,37 @@ int pipe(int fildes[2]) {
return 0;
}
-char *getwd(char *buf) {
- return syscall_getcwd(buf, 256);
+char *getcwd(char *buf, size_t size) {
+ return (char *)syscall_getcwd(buf, size);
}
-char *getcwd(char *buf, size_t size) {
- return syscall_getcwd(buf, size);
+char *getwd(char *buf) {
+ return getcwd(buf, 256);
}
int lstat(const char *path, struct stat *buf) {
return stat(path, buf);
}
int mkdir(const char *pathname, mode_t mode) {
- return syscall_mkdir(pathname, mode);
+ return syscall_mkdir((char *)pathname, mode);
}
int chdir(const char *path) {
- return syscall_chdir(path);
+ return syscall_chdir((char*)path);
}
unsigned int sleep(unsigned int seconds) {
syscall_nanosleep(seconds, 0);
return 0;
}
+int usleep(useconds_t usec) {
+ syscall_nanosleep(0, usec / 10000);
+ return 0;
+}
+
+
char _username[256];
char *getlogin(void) {
#define LINE_LEN 4096
@@ -275,7 +280,7 @@ char *getlogin(void) {
}
fclose(passwd);
- return &_username;
+ return (char *)&_username;
}
int dup2(int oldfd, int newfd) {
@@ -289,7 +294,7 @@ DIR * opendir (const char * dirname) {
return NULL;
}
- DIR * dir = malloc(sizeof(DIR));
+ DIR * dir = (DIR *)malloc(sizeof(DIR));
dir->fd = fd;
dir->cur_entry = -1;
return dir;
@@ -522,7 +527,7 @@ int getgroups(int size, gid_t list[]) {
return 0;
}
-pid_t wait3(int *status, int options, struct rusage *rusage) {
+pid_t wait3(int *status, int options, void *rusage) {
return wait(status);
}
View
@@ -4,11 +4,6 @@
#include <unistd.h>
#include <sys/ioctl.h>
-#ifdef __toaru__
-#include <syscall.h>
-int usleep(useconds_t time) { syscall_nanosleep(0, time / 10000); }
-#endif
-
#define MAX_SPEED 2
#define INITIAL_SNOW 40
#define INCREMENTAL_SNOW 10
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011 Kevin Lange. All rights reserved.
+ * Copyright (c) 2011-2013 Kevin Lange. All rights reserved.
*
* Developed by: Kevin Lange
* http://github.com/klange/nyancat
@@ -70,14 +70,6 @@
#undef ECHO
#endif
-#ifndef usleep
-#include <syscall.h>
-
-int usleep(useconds_t time) {
- syscall_nanosleep(0, time / 10000);
-}
-#endif
-
/*
* telnet.h contains some #defines for the various
* commands, escape characters, and modes for telnet.
@@ -90,7 +82,7 @@ int usleep(useconds_t time) {
* The animation frames are stored separately in
* this header so they don't clutter the core source
*/
-#include "nyancat-animation.h"
+#include "animation.h"
/*
* Color palette to use for final output
@@ -440,14 +432,14 @@ int main(int argc, char ** argv) {
if (sb[0] == TTYPE) {
/* This was a response to the TTYPE command, meaning
* that this should be a terminal type */
- alarm(0);
+ alarm(2);
strcpy(term, &sb[2]);
done++;
}
else if (sb[0] == NAWS) {
/* This was a response to the NAWS command, meaning
* that this should be a window size */
- alarm(0);
+ alarm(2);
terminal_width = sb[2];
done++;
}
@@ -518,6 +510,7 @@ int main(int argc, char ** argv) {
}
}
}
+ alarm(0);
} else {
/* We are running standalone, retrieve the
* terminal type from the environment. */
@@ -542,7 +535,6 @@ int main(int argc, char ** argv) {
terminal_width = 80;
}
-
/* Do our terminal detection */
if (strstr(term, "xterm")) {
ttype = 1; /* 256-color, spaces */
@@ -574,18 +566,18 @@ int main(int argc, char ** argv) {
switch (ttype) {
case 1:
colors[','] = "\033[48;5;17m"; /* Blue background */
- colors['.'] = "\033[48;5;15m"; /* White stars */
- colors['\''] = "\033[48;5;0m"; /* Black border */
+ colors['.'] = "\033[48;5;231m"; /* White stars */
+ colors['\''] = "\033[48;5;16m"; /* Black border */
colors['@'] = "\033[48;5;230m"; /* Tan poptart */
colors['$'] = "\033[48;5;175m"; /* Pink poptart */
colors['-'] = "\033[48;5;162m"; /* Red poptart */
- colors['>'] = "\033[48;5;9m"; /* Red rainbow */
- colors['&'] = "\033[48;5;202m"; /* Orange rainbow */
- colors['+'] = "\033[48;5;11m"; /* Yellow Rainbow */
- colors['#'] = "\033[48;5;10m"; /* Green rainbow */
+ colors['>'] = "\033[48;5;196m"; /* Red rainbow */
+ colors['&'] = "\033[48;5;214m"; /* Orange rainbow */
+ colors['+'] = "\033[48;5;226m"; /* Yellow Rainbow */
+ colors['#'] = "\033[48;5;118m"; /* Green rainbow */
colors['='] = "\033[48;5;33m"; /* Light blue rainbow */
colors[';'] = "\033[48;5;19m"; /* Dark blue rainbow */
- colors['*'] = "\033[48;5;8m"; /* Gray cat face */
+ colors['*'] = "\033[48;5;240m"; /* Gray cat face */
colors['%'] = "\033[48;5;175m"; /* Pink cheeks */
break;
case 2:
File renamed without changes.

0 comments on commit 4fc6fe7

Please sign in to comment.