Skip to content

Commit

Permalink
- added updates for new c simulation runtime
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@10340 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Willi Braun committed Nov 8, 2011
1 parent b718cec commit 6d4bfd9
Show file tree
Hide file tree
Showing 10 changed files with 1,258 additions and 6 deletions.
4 changes: 2 additions & 2 deletions SimulationRuntime/c/ModelicaExternalC/Makefile.in
@@ -1,7 +1,7 @@
CC = @CC@
CFLAGS := @CFLAGS@
CPPFLAGS := @CPPFLAGS@ -I.. -Dlinux -Dstatic=
OBJS = ModelicaInternal.o ModelicaStrings.o ModelicaTablesImpl.o
OBJS = ModelicaInternal.o ModelicaStrings.o ModelicaTablesImpl.o tables.o
AR = ar -ru

all: libModelicaExternalC.a
Expand All @@ -14,4 +14,4 @@ clean:
rm -f libModelicaExternalC.a $(OBJS)

Makefile: Makefile.in
cd ../../; ./config.status
cd ../../../; ./config.status
68 changes: 68 additions & 0 deletions SimulationRuntime/c/ModelicaExternalC/ModelicaUtilities.c
@@ -0,0 +1,68 @@
/*
* This file is part of OpenModelica.
*
* Copyright (c) 1998-CurrentYear, Linköping University,
* Department of Computer and Information Science,
* SE-58183 Linköping, Sweden.
*
* All rights reserved.
*
* THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3
* AND THIS OSMC PUBLIC LICENSE (OSMC-PL).
* ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S
* ACCEPTANCE OF THE OSMC PUBLIC LICENSE.
*
* The OpenModelica software and the Open Source Modelica
* Consortium (OSMC) Public License (OSMC-PL) are obtained
* from Linköping University, either from the above address,
* from the URLs: http://www.ida.liu.se/projects/OpenModelica or
* http://www.openmodelica.org, and in the OpenModelica distribution.
* GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
*
* This program is distributed WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
* IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS
* OF OSMC-PL.
*
* See the full OSMC Public License conditions for more details.
*
*/

#include "ModelicaUtilities.h"
#include "modelica_string.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>

void ModelicaMessage(const char* string) {
ModelicaFormatMessage("%s", string);
}

void ModelicaFormatMessage(const char* string,...) {
va_list args;
va_start(args, string);
vfprintf(stdout, string, args);
va_end(args);
fflush(stdout);
}

void ModelicaError(const char* string) {
ModelicaFormatError("%s", string);
}

void ModelicaFormatError(const char* string, ...) {
va_list args;
va_start(args, string);
vfprintf(stderr, string, args);
va_end(args);
fflush(stderr);
}

char* ModelicaAllocateString(size_t len) {
return alloc_modelica_string(len);
}

char* ModelicaAllocateStringWithErrorReturn(size_t len) {
return alloc_modelica_string(len);
}
17 changes: 17 additions & 0 deletions SimulationRuntime/c/ModelicaExternalC/ModelicaUtilities.h
@@ -0,0 +1,17 @@
#ifndef MODELICA_UTILITIES_H
#define MODELICA_UTILITIES_H

#include <stddef.h>
/*
* Utility functions for external functions.
* The functionality is defined in the Modelica 2.x and 3.x specifications.
*/

extern void ModelicaMessage(const char* string);
extern void ModelicaFormatMessage(const char* string,...);
extern void ModelicaError(const char* string);
extern void ModelicaFormatError(const char* string, ...);
extern char* ModelicaAllocateString(size_t len);
extern char* ModelicaAllocateStringWithErrorReturn(size_t len);

#endif /* MODELICA_UTILITIES_H */
2 changes: 1 addition & 1 deletion SimulationRuntime/c/ModelicaExternalC/tables.cpp
Expand Up @@ -42,7 +42,7 @@
#include <cstdarg>
#include <cctype>

#include "simulation_runtime.h"
//#include "simulation_runtime.h"

#include "tables.h"

Expand Down
47 changes: 47 additions & 0 deletions SimulationRuntime/c/util/Makefile.in
@@ -0,0 +1,47 @@
CC = @CC@
ANSI= #-ansi
CFLAGS := @CFLAGS@ -Wall $(ANSI) -pedantic $(EXTRA_CFLAGS)
CPPFLAGS := @CPPFLAGS@ -Wall $(ANSI) $(EXTRA_CFLAGS) -I. -I.. -I../meta
AR = ar -ru
FFLAGS = -O -fexceptions

OBJS = boolean_array.o index_spec.o integer_array.o memory_pool.o \
base_array.o real_array.o string_array.o utility.o \
modelica_string.o division.o\
java_interface.o rtclock.o

HFILES = \
base_array.h \
boolean_array.h \
division.h \
index_spec.h \
integer_array.h \
java_interface.h \
jni.h \
jni_md.h \
jni_md_solaris.h \
jni_md_windows.h \
memory_pool.h \
modelica.h \
modelica_string.h \
real_array.h \
rtclock.h \
string_array.h \
utility.h

LIBS = libutil.a

.PHONY : libutil.a clean

all : libutil.a

libutil.a : $(OBJS) $(HFILES)
$(AR) $@ $(OBJS)
ranlib $@

clean :
rm -f libutils.a
rm -f $(OBJS)

Makefile: Makefile.in
cd ../../../; ./config.status

0 comments on commit 6d4bfd9

Please sign in to comment.