Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Tarassov2011-11-04 23:54:20 +0000
committerEugene Tarassov2011-11-04 23:54:20 +0000
commitbdab11db0393565168741b60e98c3c4f6f7b13d8 (patch)
treec63a8091d39c2e670f4c5548e1d26d3dd4c2bf83
parent5ad078255b00227abde90dc35b8e5c0fee7b882a (diff)
downloadorg.eclipse.tcf.agent-bdab11db0393565168741b60e98c3c4f6f7b13d8.tar.gz
org.eclipse.tcf.agent-bdab11db0393565168741b60e98c3c4f6f7b13d8.tar.xz
org.eclipse.tcf.agent-bdab11db0393565168741b60e98c3c4f6f7b13d8.zip
TCF Agent: macro defs _FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE _GNU_SOURCE are moved to .c files that need them instead of being global.
-rw-r--r--Makefile.inc1
-rw-r--r--framework/asyncreq.c13
-rw-r--r--framework/asyncreq.h2
-rw-r--r--framework/channel.c4
-rw-r--r--framework/channel_pipe.c4
-rw-r--r--framework/channel_tcp.c8
-rw-r--r--framework/json.c4
-rw-r--r--framework/json.h2
-rw-r--r--framework/mdep.c7
-rw-r--r--framework/mdep.h16
-rw-r--r--framework/plugins.c4
-rw-r--r--framework/streams.c2
-rw-r--r--framework/streams.h4
-rw-r--r--services/filesystem.c15
-rw-r--r--services/processes.c4
-rw-r--r--services/tcf_elf.c11
16 files changed, 66 insertions, 35 deletions
diff --git a/Makefile.inc b/Makefile.inc
index 57273f63..c98a07c0 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -60,7 +60,6 @@ ifeq ($(OPSYS),GNU/Linux)
endif
ifneq ($(OPSYS),Windows)
- OPTS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE
OPTS += -Wall
ifneq ($(CC),g++)
OPTS += -Wmissing-prototypes
diff --git a/framework/asyncreq.c b/framework/asyncreq.c
index b218ffbd..19ddc61e 100644
--- a/framework/asyncreq.c
+++ b/framework/asyncreq.c
@@ -13,6 +13,13 @@
* Wind River Systems - initial API and implementation
*******************************************************************************/
+#if defined(__GNUC__) && _FILE_OFFSET_BITS != 64
+# ifdef _FILE_OFFSET_BITS
+# undef _FILE_OFFSET_BITS
+# endif
+# define _FILE_OFFSET_BITS 64
+#endif
+
#include <config.h>
#include <assert.h>
#include <stddef.h>
@@ -71,7 +78,7 @@ static void * worker_thread_handler(void * x) {
break;
case AsyncReqSeekRead: /* File read at offset */
- req->u.fio.rval = pread(req->u.fio.fd, req->u.fio.bufp, req->u.fio.bufsz, req->u.fio.offset);
+ req->u.fio.rval = pread(req->u.fio.fd, req->u.fio.bufp, req->u.fio.bufsz, (off_t)req->u.fio.offset);
if (req->u.fio.rval == -1) {
req->error = errno;
assert(req->error);
@@ -79,7 +86,7 @@ static void * worker_thread_handler(void * x) {
break;
case AsyncReqSeekWrite: /* File write at offset */
- req->u.fio.rval = pwrite(req->u.fio.fd, req->u.fio.bufp, req->u.fio.bufsz, req->u.fio.offset);
+ req->u.fio.rval = pwrite(req->u.fio.fd, req->u.fio.bufp, req->u.fio.bufsz, (off_t)req->u.fio.offset);
if (req->u.fio.rval == -1) {
req->error = errno;
assert(req->error);
@@ -226,7 +233,7 @@ void async_req_post(AsyncReqInfo * req) {
case AsyncReqSeekWrite:
memset(&req->u.fio.aio, 0, sizeof(req->u.fio.aio));
req->u.fio.aio.aio_fildes = req->u.fio.fd;
- req->u.fio.aio.aio_offset = req->u.fio.offset;
+ req->u.fio.aio.aio_offset = (off_t)req->u.fio.offset;
req->u.fio.aio.aio_buf = req->u.fio.bufp;
req->u.fio.aio.aio_nbytes = req->u.fio.bufsz;
req->u.fio.aio.aio_sigevent.sigev_notify = SIGEV_THREAD;
diff --git a/framework/asyncreq.h b/framework/asyncreq.h
index 25f2914c..70706dd4 100644
--- a/framework/asyncreq.h
+++ b/framework/asyncreq.h
@@ -56,7 +56,7 @@ struct AsyncReqInfo {
struct {
/* In */
int fd;
- off_t offset;
+ int64_t offset;
void * bufp;
size_t bufsz;
diff --git a/framework/channel.c b/framework/channel.c
index 333aea02..edb0b84f 100644
--- a/framework/channel.c
+++ b/framework/channel.c
@@ -76,14 +76,14 @@ static void write_block_all(OutputStream * out, const char * bytes, size_t size)
}
}
-static ssize_t splice_block_all(OutputStream * out, int fd, size_t size, off_t * offset) {
+static ssize_t splice_block_all(OutputStream * out, int fd, size_t size, int64_t * offset) {
char buffer[0x400];
ssize_t rd = 0;
assert(is_dispatch_thread());
if (size > sizeof(buffer)) size = sizeof(buffer);
if (offset != NULL) {
- rd = pread(fd, buffer, size, *offset);
+ rd = pread(fd, buffer, size, (off_t)*offset);
if (rd > 0) *offset += rd;
}
else {
diff --git a/framework/channel_pipe.c b/framework/channel_pipe.c
index ae6c4a42..1a74d9e1 100644
--- a/framework/channel_pipe.c
+++ b/framework/channel_pipe.c
@@ -259,14 +259,14 @@ static void pipe_write_block_stream(OutputStream * out, const char * bytes, size
while (cnt < size) write_stream(out, (unsigned char)bytes[cnt++]);
}
-static ssize_t pipe_splice_block_stream(OutputStream * out, int fd, size_t size, off_t * offset) {
+static ssize_t pipe_splice_block_stream(OutputStream * out, int fd, size_t size, int64_t * offset) {
ssize_t rd = 0;
char buffer[BUF_SIZE];
assert(is_dispatch_thread());
if (size == 0) return 0;
if (size > BUF_SIZE) size = BUF_SIZE;
if (offset != NULL) {
- rd = pread(fd, buffer, size, *offset);
+ rd = pread(fd, buffer, size, (off_t)*offset);
if (rd > 0) *offset += rd;
}
else {
diff --git a/framework/channel_tcp.c b/framework/channel_tcp.c
index 5c3e3aaa..2d69de66 100644
--- a/framework/channel_tcp.c
+++ b/framework/channel_tcp.c
@@ -19,6 +19,10 @@
* Implements input and output stream over TCP/IP transport.
*/
+#if defined(__GNUC__) && !defined(_GNU_SOURCE)
+# define _GNU_SOURCE
+#endif
+
#include <config.h>
#include <fcntl.h>
#include <stddef.h>
@@ -453,7 +457,7 @@ static void tcp_write_block_stream(OutputStream * out, const char * bytes, size_
while (cnt < size) write_stream(out, (unsigned char)bytes[cnt++]);
}
-static ssize_t tcp_splice_block_stream(OutputStream * out, int fd, size_t size, off_t * offset) {
+static ssize_t tcp_splice_block_stream(OutputStream * out, int fd, size_t size, int64_t * offset) {
assert(is_dispatch_thread());
if (size == 0) return 0;
#if ENABLE_Splice
@@ -510,7 +514,7 @@ static ssize_t tcp_splice_block_stream(OutputStream * out, int fd, size_t size,
char buffer[BUF_SIZE];
if (size > BUF_SIZE) size = BUF_SIZE;
if (offset != NULL) {
- rd = pread(fd, buffer, size, *offset);
+ rd = pread(fd, buffer, size, (off_t)*offset);
if (rd > 0) *offset += rd;
}
else {
diff --git a/framework/json.c b/framework/json.c
index 185830e9..0ebf0e78 100644
--- a/framework/json.c
+++ b/framework/json.c
@@ -736,7 +736,7 @@ void json_splice_binary(OutputStream * out, int fd, size_t size) {
json_splice_binary_offset(out, fd, size, NULL);
}
-void json_splice_binary_offset(OutputStream * out, int fd, size_t size, off_t * offset) {
+void json_splice_binary_offset(OutputStream * out, int fd, size_t size, int64_t * offset) {
if (out->supports_zero_copy && size > 0) {
write_stream(out, '(');
json_write_ulong(out, size);
@@ -756,7 +756,7 @@ void json_splice_binary_offset(OutputStream * out, int fd, size_t size, off_t *
while (size > 0) {
ssize_t rd = 0;
if (offset != NULL) {
- rd = pread(fd, buffer, size < sizeof(buffer) ? size : sizeof(buffer), *offset);
+ rd = pread(fd, buffer, size < sizeof(buffer) ? size : sizeof(buffer), (off_t)*offset);
if (rd > 0) *offset += rd;
}
else {
diff --git a/framework/json.h b/framework/json.h
index 15b30f52..5a414c15 100644
--- a/framework/json.h
+++ b/framework/json.h
@@ -80,7 +80,7 @@ extern void write_service_error(OutputStream * out, int err, const char * servic
extern char * json_read_alloc_binary(InputStream * inp, size_t * size);
extern void json_write_binary(OutputStream * out, const void * data, size_t size);
extern void json_splice_binary(OutputStream * out, int fd, size_t size);
-extern void json_splice_binary_offset(OutputStream * out, int fd, size_t size, off_t * offset);
+extern void json_splice_binary_offset(OutputStream * out, int fd, size_t size, int64_t * offset);
typedef struct JsonReadBinaryState {
/* Private members */
diff --git a/framework/mdep.c b/framework/mdep.c
index a284c7b5..20bab44c 100644
--- a/framework/mdep.c
+++ b/framework/mdep.c
@@ -20,6 +20,13 @@
* agent code portable between Linux, Windows, VxWorks and potentially other OSes.
*/
+#if defined(__GNUC__) && _FILE_OFFSET_BITS != 64
+# ifdef _FILE_OFFSET_BITS
+# undef _FILE_OFFSET_BITS
+# endif
+# define _FILE_OFFSET_BITS 64
+#endif
+
#include <config.h>
#include <stdlib.h>
#include <stdio.h>
diff --git a/framework/mdep.h b/framework/mdep.h
index bd003745..401b105b 100644
--- a/framework/mdep.h
+++ b/framework/mdep.h
@@ -89,14 +89,6 @@ typedef int socklen_t;
#if defined(__CYGWIN__)
-#ifndef _LARGEFILE_SOURCE
-#error "Need CC command line option: -D_LARGEFILE_SOURCE"
-#endif
-
-#ifndef _GNU_SOURCE
-#error "Need CC command line option: -D_GNU_SOURCE"
-#endif
-
#include <sys/unistd.h>
#else /* not __CYGWIN__ */
@@ -313,14 +305,6 @@ extern int loc_clock_gettime(int, struct timespec *);
#else
/* Linux, BSD, MacOS, UNIX */
-#ifndef _LARGEFILE_SOURCE
-#error "Need CC command line option: -D_LARGEFILE_SOURCE"
-#endif
-
-#ifndef _GNU_SOURCE
-#error "Need CC command line option: -D_GNU_SOURCE"
-#endif
-
#include <unistd.h>
#include <memory.h>
#include <sys/types.h>
diff --git a/framework/plugins.c b/framework/plugins.c
index 09efb5d5..2a1289ae 100644
--- a/framework/plugins.c
+++ b/framework/plugins.c
@@ -21,6 +21,10 @@
* Plugins system.
*/
+#if defined(__GNUC__) && !defined(_GNU_SOURCE)
+# define _GNU_SOURCE
+#endif
+
#include <config.h>
#if ENABLE_Plugins
diff --git a/framework/streams.c b/framework/streams.c
index 552c0876..fda2ddd8 100644
--- a/framework/streams.c
+++ b/framework/streams.c
@@ -40,7 +40,7 @@ void (write_block_stream)(OutputStream * out, const char * bytes, size_t size) {
out->write_block(out, bytes, size);
}
-ssize_t (splice_block_stream)(OutputStream * out, int fd, size_t size, off_t * offset) {
+ssize_t (splice_block_stream)(OutputStream * out, int fd, size_t size, int64_t * offset) {
return out->splice_block(out, fd, size, offset);
}
diff --git a/framework/streams.h b/framework/streams.h
index dd06f0ea..fb4a787b 100644
--- a/framework/streams.h
+++ b/framework/streams.h
@@ -41,7 +41,7 @@ struct OutputStream {
unsigned char * end;
void (*write)(OutputStream * stream, int byte);
void (*write_block)(OutputStream * stream, const char * bytes, size_t size);
- ssize_t (*splice_block)(OutputStream * stream, int fd, size_t size, off_t * offset);
+ ssize_t (*splice_block)(OutputStream * stream, int fd, size_t size, int64_t * offset);
};
typedef struct InputStream InputStream;
@@ -69,7 +69,7 @@ extern int (read_stream)(InputStream * inp);
extern int (peek_stream)(InputStream * inp);
extern void (write_stream)(OutputStream * out, int b);
extern void (write_block_stream)(OutputStream * out, const char * bytes, size_t size);
-extern ssize_t (splice_block_stream)(OutputStream * out, int fd, size_t size, off_t * offset);
+extern ssize_t (splice_block_stream)(OutputStream * out, int fd, size_t size, int64_t * offset);
extern void write_string(OutputStream * out, const char * str);
extern void write_stringz(OutputStream * out, const char * str);
diff --git a/services/filesystem.c b/services/filesystem.c
index 7a3030c2..e057bc67 100644
--- a/services/filesystem.c
+++ b/services/filesystem.c
@@ -17,6 +17,17 @@
* Target service implementation: file system access (TCF name FileSystem)
*/
+#if defined(__GNUC__) && !defined(_GNU_SOURCE)
+# define _GNU_SOURCE
+#endif
+
+#if defined(__GNUC__) && _FILE_OFFSET_BITS != 64
+# ifdef _FILE_OFFSET_BITS
+# undef _FILE_OFFSET_BITS
+# endif
+# define _FILE_OFFSET_BITS 64
+#endif
+
#include <config.h>
#if SERVICE_FileSystem
@@ -728,7 +739,7 @@ static void command_read(char * token, Channel * c) {
}
else {
req->info.type = AsyncReqSeekRead;
- req->info.u.fio.offset = (off_t)offset;
+ req->info.u.fio.offset = offset;
}
req->info.u.fio.fd = h->file;
req->info.u.fio.bufp = loc_alloc(len);
@@ -779,7 +790,7 @@ static void command_write(char * token, Channel * c) {
}
else {
req->info.type = AsyncReqSeekWrite;
- req->info.u.fio.offset = (off_t)offset;
+ req->info.u.fio.offset = offset;
}
req->info.u.fio.fd = h->file;
req->info.u.fio.bufp = loc_alloc(len);
diff --git a/services/processes.c b/services/processes.c
index 5f9fc044..78a2a565 100644
--- a/services/processes.c
+++ b/services/processes.c
@@ -23,6 +23,10 @@
/* TODO: It should be possible to filter processes on a criteria (user, name, etc) */
+#if defined(__GNUC__) && !defined(_GNU_SOURCE)
+# define _GNU_SOURCE
+#endif
+
#include <config.h>
#if SERVICE_Processes || SERVICE_Terminals
diff --git a/services/tcf_elf.c b/services/tcf_elf.c
index 14540342..df2a4330 100644
--- a/services/tcf_elf.c
+++ b/services/tcf_elf.c
@@ -17,6 +17,17 @@
* This module implements reading and caching of ELF files.
*/
+#if defined(__GNUC__) && !defined(_GNU_SOURCE)
+# define _GNU_SOURCE
+#endif
+
+#if defined(__GNUC__) && _FILE_OFFSET_BITS != 64
+# ifdef _FILE_OFFSET_BITS
+# undef _FILE_OFFSET_BITS
+# endif
+# define _FILE_OFFSET_BITS 64
+#endif
+
#include <config.h>
#if ENABLE_ELF

Back to the top