From f323b4a77d95dae601217f01f91b87bfa3e2e741 Mon Sep 17 00:00:00 2001 From: Tommy Olofsson <tommyo@calvin.control.lth.se> Date: Thu, 20 Mar 2014 20:06:32 +0100 Subject: [PATCH] Archive builds with vx toolchain. --- .gitignore | 4 ++++ lib/c/Makefile | 17 ++++++++++++++--- lib/c/labcomm.h | 10 ++++++++-- lib/c/labcomm_compat_vxworks.h | 8 ++++++++ lib/c/labcomm_decoder.c | 8 ++++++-- lib/c/labcomm_error.h | 2 ++ lib/c/labcomm_fd_reader.c | 2 +- lib/c/labcomm_fd_writer.c | 2 +- lib/c/labcomm_private.h | 4 ++-- lib/c/labcomm_scheduler.h | 8 ++++++-- lib/c/labcomm_scheduler_private.h | 7 ++++++- 11 files changed, 58 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index b9f0108..f1056e8 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,7 @@ lib/c/liblabcomm.a compiler/AST/ compiler/labComm.jar +examples/twoway/gen/ +lib/csharp/labcomm.dll +lib/java/gen/ +lib/java/labcomm.jar diff --git a/lib/c/Makefile b/lib/c/Makefile index 886d818..c5af86b 100644 --- a/lib/c/Makefile +++ b/lib/c/Makefile @@ -1,8 +1,19 @@ ## Macros UNAME_S=$(shell uname -s) +ALL_DEPS=liblabcomm.a liblabcomm.so.1 + ifeq ($(UNAME_S),Linux) - CC=gcc - CFLAGS=-std=c99 -g -Wall -Werror -O3 -I. -Itest + CFLAGS=-std=c99 -g -Wall -Werror -O3 -I. -Itest + ifndef TARGET + CC=gcc + else ifeq ($(TARGET),vx) + CC=i586-wrs-vxworks-gcc + LD=i586-wrs-vxworks-ld + ALL_DEPS:=$(filter-out %.so.1, $(ALL_DEPS)) + CFLAGS:=$(CFLAGS) -DLABCOMM_COMPAT=\"labcomm_compat_vxworks.h\" + else + @echo 'Invalid target.' + endif LDFLAGS=-L. LDLIBS=-llabcomm -lrt MAKESHARED=gcc -o $1 -shared -Wl,-soname,$2 $3 -lc -lrt @@ -57,7 +68,7 @@ endif .PHONY: all run-test clean distclean -all: liblabcomm.a liblabcomm.so.1 +all: $(ALL_DEPS) liblabcomm.a: $(OBJS) ar -r $@ $^ diff --git a/lib/c/labcomm.h b/lib/c/labcomm.h index b83cdf8..0c264bc 100644 --- a/lib/c/labcomm.h +++ b/lib/c/labcomm.h @@ -24,8 +24,14 @@ #define _LABCOMM_H_ #include <stdarg.h> -#include <stdint.h> -#include <unistd.h> + +#ifdef LABCOMM_COMPAT + #include LABCOMM_COMPAT +#else + #include <stdint.h> + #include <unistd.h> +#endif + #include "labcomm_error.h" #include "labcomm_scheduler.h" diff --git a/lib/c/labcomm_compat_vxworks.h b/lib/c/labcomm_compat_vxworks.h index f05ee78..00a2b5a 100644 --- a/lib/c/labcomm_compat_vxworks.h +++ b/lib/c/labcomm_compat_vxworks.h @@ -1,7 +1,13 @@ +#ifndef _LABCOMM_COMPAT_VXWORKS_H_ +#define _LABCOMM_COMPAT_VXWORKS_H_ + #ifndef __VXWORKS__ #error "__VXWORKS__" not defined #endif +#include <types/vxTypes.h> +#include <stdio.h> + #if (CPU == PPC603) #undef _LITTLE_ENDIAN #endif @@ -10,3 +16,5 @@ #undef _BIG_ENDIAN #endif +#endif + diff --git a/lib/c/labcomm_decoder.c b/lib/c/labcomm_decoder.c index d6ecd5e..0606e6f 100644 --- a/lib/c/labcomm_decoder.c +++ b/lib/c/labcomm_decoder.c @@ -199,7 +199,9 @@ static int decode_typedef_or_sample(struct labcomm_decoder *d, int kind) LABCOMM_IOCTL_WRITER_GET_BYTES_WRITTEN, &signature.size); if (err < 0) { - fprintf(stderr, "Failed to get size: %s\n", strerror(-err)); + /* fprintf(stderr, "Failed to get size: %s\n", strerror(-err)); */ + labcomm_error_warning(d->error, LABCOMM_ERROR_BAD_WRITER, + "Failed to get size: %s\n", strerror(-err)); result = -ENOENT; goto free_signature_name; } @@ -207,7 +209,9 @@ static int decode_typedef_or_sample(struct labcomm_decoder *d, int kind) LABCOMM_IOCTL_WRITER_GET_BYTE_POINTER, &signature.signature); if (err < 0) { - fprintf(stderr, "Failed to get pointer: %s\n", strerror(-err)); + /* fprintf(stderr, "Failed to get pointer: %s\n", strerror(-err)); */ + labcomm_error_warning(d->error, LABCOMM_ERROR_BAD_WRITER, + "Failed to get pointer: %s\n", strerror(-err)); result = -ENOENT; goto free_signature_name; } diff --git a/lib/c/labcomm_error.h b/lib/c/labcomm_error.h index dd124c9..80e4805 100644 --- a/lib/c/labcomm_error.h +++ b/lib/c/labcomm_error.h @@ -64,5 +64,7 @@ LABCOMM_ERROR(LABCOMM_ERROR_MEMORY, "Could not allocate memory") LABCOMM_ERROR(LABCOMM_ERROR_USER_DEF, "User defined error") +LABCOMM_ERROR(LABCOMM_ERROR_BAD_WRITER, + "Decoder: writer_ioctl() failed") #endif diff --git a/lib/c/labcomm_fd_reader.c b/lib/c/labcomm_fd_reader.c index e397c84..65a9fbb 100644 --- a/lib/c/labcomm_fd_reader.c +++ b/lib/c/labcomm_fd_reader.c @@ -98,7 +98,7 @@ static int fd_fill(struct labcomm_reader *r, int err; r->pos = 0; - err = read(fd_reader->fd, r->data, r->data_size); + err = read(fd_reader->fd, (char *)r->data, r->data_size); if (err <= 0) { r->count = 0; r->error = -EPIPE; diff --git a/lib/c/labcomm_fd_writer.c b/lib/c/labcomm_fd_writer.c index acf6934..9ea707f 100644 --- a/lib/c/labcomm_fd_writer.c +++ b/lib/c/labcomm_fd_writer.c @@ -101,7 +101,7 @@ static int fd_flush(struct labcomm_writer *w, start = 0; err = 0; while (start < w->pos) { - err = write(fd_context->fd, &w->data[start], w->pos - start); + err = write(fd_context->fd, (char *)&w->data[start], w->pos - start); if (err <= 0) { break; } diff --git a/lib/c/labcomm_private.h b/lib/c/labcomm_private.h index ab4e315..c74c4a7 100644 --- a/lib/c/labcomm_private.h +++ b/lib/c/labcomm_private.h @@ -28,12 +28,12 @@ #else #include <endian.h> #include <stdio.h> + #include <stdint.h> + #include <unistd.h> #endif -#include <stdint.h> //#include <stdlib.h> #include <string.h> -#include <unistd.h> #include "labcomm.h" /* diff --git a/lib/c/labcomm_scheduler.h b/lib/c/labcomm_scheduler.h index 4aef48d..07f74c2 100644 --- a/lib/c/labcomm_scheduler.h +++ b/lib/c/labcomm_scheduler.h @@ -22,8 +22,12 @@ #ifndef _LABCOMM_SCHEDULER_H_ #define _LABCOMM_SCHEDULER_H_ -#include <unistd.h> -#include <stdint.h> +#ifdef LABCOMM_COMPAT + #include LABCOMM_COMPAT +#else + #include <unistd.h> + #include <stdint.h> +#endif struct labcomm_time; diff --git a/lib/c/labcomm_scheduler_private.h b/lib/c/labcomm_scheduler_private.h index cc4d50e..398552e 100644 --- a/lib/c/labcomm_scheduler_private.h +++ b/lib/c/labcomm_scheduler_private.h @@ -22,7 +22,12 @@ #ifndef _LABCOMM_SCHEDULER_PRIVATE_H_ #define _LABCOMM_SCHEDULER_PRIVATE_H_ -#include <unistd.h> +#ifdef LABCOMM_COMPAT + #include LABCOMM_COMPAT +#else + #include <unistd.h> +#endif + #include "labcomm_scheduler.h" struct labcomm_time { -- GitLab