Skip to content
Browse files

refactor

  • Loading branch information...
1 parent eb2c0e3 commit 52dac7b5be249aca6e17931a74a1d4c4667a9e73 @kr committed
Showing with 42 additions and 48 deletions.
  1. +3 −4 Makefile
  2. +25 −2 sock-bsd.c → darwin.c
  3. +1 −0 freebsd.c
  4. +13 −0 sock-linux.c → linux.c
  5. +0 −25 port-bsd.c
  6. +0 −1 port-darwin.c
  7. +0 −1 port-freebsd.c
  8. +0 −13 port-linux.c
  9. +0 −1 sock-darwin.c
  10. +0 −1 sock-freebsd.c
View
7 Makefile
@@ -4,7 +4,7 @@ CFLAGS=-Wall -Werror\
-Wformat=2\
LDFLAGS=
-OS=$(shell uname -s | tr A-Z a-z)
+OS=$(shell uname|tr A-Z a-z)
INSTALL=install
TAR=tar
@@ -12,17 +12,16 @@ VERS=$(shell ./vers.sh)
TARG=beanstalkd
MOFILE=main.o
OFILES=\
+ $(OS).o\
conn.o\
file.o\
heap.o\
job.o\
ms.o\
net.o\
- port-$(OS).o\
primes.o\
prot.o\
sd-daemon.o\
- sock-$(OS).o\
serv.o\
time.o\
tube.o\
@@ -110,4 +109,4 @@ $(TARG)-$(VERS).tar.gz: $(TARG)-$(VERS).tar
doc/beanstalkd.1 doc/beanstalkd.1.html: doc/beanstalkd.ronn
ronn $<
-sock-darwin.o sock-freebsd.o: sock-bsd.c
+freebsd.o: darwin.c
View
27 sock-bsd.c → darwin.c
@@ -1,6 +1,9 @@
+#include <stdint.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <errno.h>
#include <stdlib.h>
#include <errno.h>
-#include <sys/types.h>
#include <sys/event.h>
#include <sys/time.h>
#include "dat.h"
@@ -10,7 +13,27 @@ enum
Infinity = 1 << 30
};
-static int kq;
+static int kq;
+static char buf0[512]; /* buffer of zeros */
+
+
+/* Allocate disk space.
+ * Expects fd's offset to be 0; may also reset fd's offset to 0.
+ * Returns 0 on success, and a positive errno otherwise. */
+int
+rawfalloc(int fd, int len)
+{
+ int i, w;
+
+ for (i = 0; i < len; i += w) {
+ w = write(fd, buf0, sizeof buf0);
+ if (w == -1) return errno;
+ }
+
+ lseek(fd, 0, 0); /* do not care if this fails */
+
+ return 0;
+}
int
View
1 freebsd.c
@@ -0,0 +1 @@
+#include "darwin.c"
View
13 sock-linux.c → linux.c
@@ -1,3 +1,6 @@
+#define _XOPEN_SOURCE 600
+#include <stdint.h>
+#include <fcntl.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/epoll.h>
@@ -10,6 +13,16 @@
static int epfd;
+/* Allocate disk space.
+ * Expects fd's offset to be 0; may also reset fd's offset to 0.
+ * Returns 0 on success, and a positive errno otherwise. */
+int
+rawfalloc(int fd, int len)
+{
+ return posix_fallocate(fd, 0, len);
+}
+
+
int
sockinit(void)
{
View
25 port-bsd.c
@@ -1,25 +0,0 @@
-#include <stdint.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <errno.h>
-#include "dat.h"
-
-static char buf0[512]; /* buffer of zeros */
-
-/* Allocate disk space.
- * Expects fd's offset to be 0; may also reset fd's offset to 0.
- * Returns 0 on success, and a positive errno otherwise. */
-int
-rawfalloc(int fd, int len)
-{
- int i, w;
-
- for (i = 0; i < len; i += w) {
- w = write(fd, buf0, sizeof buf0);
- if (w == -1) return errno;
- }
-
- lseek(fd, 0, 0); /* do not care if this fails */
-
- return 0;
-}
View
1 port-darwin.c
@@ -1 +0,0 @@
-#include "port-bsd.c"
View
1 port-freebsd.c
@@ -1 +0,0 @@
-#include "port-bsd.c"
View
13 port-linux.c
@@ -1,13 +0,0 @@
-#define _XOPEN_SOURCE 600
-#include <stdint.h>
-#include <fcntl.h>
-#include "dat.h"
-
-/* Allocate disk space.
- * Expects fd's offset to be 0; may also reset fd's offset to 0.
- * Returns 0 on success, and a positive errno otherwise. */
-int
-rawfalloc(int fd, int len)
-{
- return posix_fallocate(fd, 0, len);
-}
View
1 sock-darwin.c
@@ -1 +0,0 @@
-#include "sock-bsd.c"
View
1 sock-freebsd.c
@@ -1 +0,0 @@
-#include "sock-bsd.c"

0 comments on commit 52dac7b

Please sign in to comment.
Something went wrong with that request. Please try again.