Compare commits

..

82 Commits

Author SHA1 Message Date
Janet B. Anderson
5856008613 R3.13.0.beta2 1996-09-05 14:47:19 +00:00
Marty Kraimer
f3003d9052 Remove rule for RECTYPES 1996-09-05 14:22:31 +00:00
Marty Kraimer
340ffec332 Forgot = 1996-09-05 13:42:25 +00:00
Marty Kraimer
91c6f156ff conversion should not have added .5 (bad for - numbers) 1996-09-05 13:01:27 +00:00
Marty Kraimer
2008c19e7d Forgot to save changes last time 1996-09-05 12:52:42 +00:00
Marty Kraimer
4dcb0e3ae6 Changed AB SLC500 DCM names to show that it is only for SLC500 DCM 1996-09-05 12:37:33 +00:00
Marty Kraimer
74bc7758b5 changed to show that support is for SCL500 Dcm 1996-09-05 12:36:05 +00:00
Jeff Hill
17143d0e12 wait for proper compiler installation 1996-09-04 22:51:58 +00:00
Jeff Hill
40be4d1cd5 allow vxWorks 5.1 and gnu win 32 1996-09-04 22:47:09 +00:00
Jeff Hill
d1ba9be665 installed 1996-09-04 22:41:41 +00:00
Jeff Hill
7f6bd17474 removed until the new gnu compilers are installed 1996-09-04 22:41:12 +00:00
Jeff Hill
6a534ca2b5 fixed gcc warnings 1996-09-04 22:08:50 +00:00
Jeff Hill
26ec4dd5c8 installed 1996-09-04 22:06:47 +00:00
Jeff Hill
a0db9a2eb2 not used 1996-09-04 22:06:24 +00:00
Jeff Hill
b5a102ef79 moved netdb.h include here 1996-09-04 22:04:07 +00:00
Jeff Hill
ed1491bb7b fixed gcc warnings 1996-09-04 21:59:03 +00:00
Jeff Hill
7fabc325bb added level arg to client_stat 1996-09-04 21:58:27 +00:00
Jeff Hill
5b546d2467 added vxWorks support 1996-09-04 21:54:56 +00:00
Jeff Hill
6440239832 allow use with goofy vxWorks 5.2 time spec - which has unsigned sec and
signed nsec
1996-09-04 21:53:36 +00:00
Jeff Hill
cb6c444a19 added hashed fd to fdi convert 1996-09-04 21:50:16 +00:00
Jeff Hill
c251b05020 MS Visual C defines sys_errlist in stdlib.h 1996-09-04 21:48:29 +00:00
Jeff Hill
1f7cc343c5 fixed gcc warning 1996-09-04 21:46:20 +00:00
Janet B. Anderson
d67eb28145 Top level dir no longer passed to MakeRelease 1996-09-04 21:41:36 +00:00
Jeff Hill
3001f7e82f no what on win32 1996-09-04 21:40:28 +00:00
Janet B. Anderson
3982ea7d17 Added info about new targets. 1996-09-04 21:22:34 +00:00
Jeff Hill
3fe00ec2a9 installed 1996-09-04 21:21:01 +00:00
Jeff Hill
11fa08c1e0 installed 1996-09-04 21:02:33 +00:00
Jeff Hill
b8d2273683 added GDD_NAME_PV_NAME 1996-09-04 20:58:55 +00:00
Jeff Hill
77fc9734b1 changes for MS VISC++ 1996-09-04 20:58:18 +00:00
Jeff Hill
289302f603 add GDD_NAME_PV_NAME 1996-09-04 20:55:02 +00:00
Jeff Hill
a01241aa19 fixed gcc warnings 1996-09-04 20:44:19 +00:00
Marty Kraimer
525842b076 added devABANALOG 1996-09-04 20:41:57 +00:00
Marty Kraimer
03a4c8ad01 added devABANALOG 1996-09-04 20:41:10 +00:00
Jeff Hill
8a7158b3c6 installed into CVS 1996-09-04 20:39:59 +00:00
Jeff Hill
08c57574d5 removed os depen stuff 1996-09-04 20:29:08 +00:00
Jeff Hill
a6c40247f1 (char *) cast below is for brain dead wrs prototype 1996-09-04 20:28:18 +00:00
Jeff Hill
86969d7b3a doccasdef.h 1996-09-04 20:27:02 +00:00
Jeff Hill
a3c13f6da6 use correct app type for exist test gdd, correct byte oder for mon mask, and efficient use of PV name gdd 1996-09-04 20:25:53 +00:00
Jeff Hill
0d0566253e added operator -> 1996-09-04 20:23:59 +00:00
Jeff Hill
15fda603a5 init new member cas and add arg to serverToolDebug() 1996-09-04 20:23:17 +00:00
Jeff Hill
7c0895bd82 removed operator -> and added member pv 1996-09-04 20:21:41 +00:00
Jeff Hill
5311ba4c15 removed sizeof(casEventMask::mask) for MSVISC++ 1996-09-04 20:20:44 +00:00
Jeff Hill
27b0c05bcf added missing byte swap on search reply port no 1996-09-04 20:19:47 +00:00
Jeff Hill
435208afa8 include db_access.h 1996-09-04 20:19:02 +00:00
Jeff Hill
0f1f7fc30c moved operator -> here 1996-09-04 20:18:27 +00:00
Jeff Hill
471acea0fc init new chan member 1996-09-04 20:18:03 +00:00
Jeff Hill
e122d8f4a6 use ptr not ref to satisfy MSVISC++ 1996-09-04 20:17:34 +00:00
Jeff Hill
53bde9e545 initialize new member - asyncIO 1996-09-04 20:13:16 +00:00
Jeff Hill
2ccaa6dcb6 added arg to serverToolDebugFunc() 1996-09-04 20:12:04 +00:00
Jeff Hill
8c8b971221 comment 1996-09-04 20:11:43 +00:00
Jeff Hill
dd43f91278 added new files 1996-09-04 20:10:43 +00:00
Jeff Hill
6b3a62de9f added main.cc 1996-09-04 20:09:33 +00:00
Jeff Hill
4bd45337bf add getEnums() stub 1996-09-04 20:08:55 +00:00
Jeff Hill
9351447cf2 removed main() 1996-09-04 20:08:33 +00:00
Jeff Hill
b9cdf72ee1 added defualt copy constructor fer MSVISC++ 1996-09-04 20:07:52 +00:00
Jeff Hill
81000e9391 added include of os specific area 1996-09-04 20:06:15 +00:00
Jeff Hill
19b81912fb added mt makefiles 1996-09-04 20:04:57 +00:00
Jeff Hill
b7df13b4fe fixed gcc warning 1996-09-04 20:02:32 +00:00
Jeff Hill
2f3befc845 test for non-nill piiu under vxWorks 1996-09-04 20:02:00 +00:00
Jeff Hill
826b68b652 string id resource now copies id 1996-09-04 19:57:11 +00:00
Janet B. Anderson
aece23e6ee Removed VPATH (puts ../$(INSTALL_LOCATION) in search path) 1996-09-04 19:19:52 +00:00
Janet B. Anderson
3a9ddfbdbb Change ARCHS and ACTIONS defs to +=. 1996-09-04 18:26:44 +00:00
Janet B. Anderson
11bdb5f6d4 Removed cvsignore files. 1996-09-04 18:22:48 +00:00
Janet B. Anderson
741450ce9e Removed copy of vxWorks files. 1996-09-04 18:18:25 +00:00
Janet B. Anderson
868e6c417d Modified dependency. 1996-09-04 18:17:18 +00:00
Marty Kraimer
0c19e23835 added new rules 1996-09-04 15:29:48 +00:00
Marty Kraimer
342ffb5d83 fixed bugs repoeted in 3.13 beta1 1996-09-04 15:28:56 +00:00
Marty Kraimer
afa44fae79 added routines to obtain options for link field 1996-09-04 15:27:53 +00:00
Marty Kraimer
333b379287 fixed bugs 1996-09-04 15:26:58 +00:00
Marty Kraimer
36f74c934e removed event throttling code 1996-09-04 15:25:54 +00:00
Marty Kraimer
8f41686a98 If process routine found udf true it did not perform normal record completion 1996-09-04 15:25:19 +00:00
Marty Kraimer
75feb3a5d4 Changes for 3.13 1996-09-04 15:23:54 +00:00
Marty Kraimer
50ace741fe removed obsolete event throttling code 1996-09-04 15:23:22 +00:00
Marty Kraimer
036cd8dd26 Added INC+= 1996-08-27 16:11:30 +00:00
Marty Kraimer
9758aa4a45 Error on special gave wrong error message 1996-08-27 16:04:31 +00:00
Marty Kraimer
cf1cb554f6 dbPutField - Call special before converting to DB or CA 1996-08-27 16:03:42 +00:00
Marty Kraimer
ee68f746c6 Sometimes sdr2recordtype can't find field name 1996-08-27 15:48:31 +00:00
Jeff Hill
85f2cf5833 No longer used 1996-08-27 15:45:13 +00:00
Jim Kowalkowski
5819ac0c48 final repairs to string functions, put() functions, and error code printing 1996-08-27 13:05:10 +00:00
Jim Kowalkowski
3e26a12948 completed fixes for the aitString and fixed string management 1996-08-23 20:29:36 +00:00
Jim Kowalkowski
279385ecb9 made dump functions print more useful information 1996-08-23 20:28:46 +00:00
Jim Kowalkowski
75c91c8035 More fixes to make strings and fixed string work better. 1996-08-22 21:05:43 +00:00
122 changed files with 4925 additions and 4089 deletions

View File

@@ -10,6 +10,9 @@
# [-b] - For fully built release
#
# $Log$
# Revision 1.8 1996/07/02 13:45:09 jba
# Added dbd and base/config dirs. Removed epics/config and base/rec.
#
# Revision 1.7 1996/06/25 21:54:42 jba
# Command line parm now base dir
#
@@ -75,9 +78,13 @@ fi
FULLY_BUILT=NO
if [ "${2}" = "-b" ]; then
if [ "${1}" = "-b" ]; then
FULLY_BUILT=YES
shift
if [ "${1}" != "." ]; then
echo "TOP: Cannot create a fully built release.";
exit 1;
fi
fi
# Retrieve EPICS release string from src/include/epicsVersion.h

View File

@@ -22,11 +22,11 @@ include $(TOP)/config/RULES_TOP
release:
@echo TOP: Creating Release...
@./MakeRelease ${TOP}
@./MakeRelease
built_release: install
built_release:
@echo TOP: Creating Fully Built Release...
@./MakeRelease ${TOP} -b
@./MakeRelease -b $(INSTALL_LOCATION)
uninstall::
@DIR1=`pwd`;cd $(INSTALL_LOCATION);DIR2=`pwd`;cd $$DIR1;\

36
README
View File

@@ -1,7 +1,7 @@
$Id$
----------------------------------------------------------------------------
3.12 EPICS BASE Notes and Build Instructions.
3.13 EPICS BASE Notes and Build Instructions.
- By Matthew Needes
----------------------------------------------------------------------------
@@ -41,19 +41,43 @@ Notes:
1.3 To build EPICS:
cd epics/base
gnumake - To build and install EPICS.
gnumake - To install include files, build and install EPICS.
(Same as "gnumake inc install")
gnumake all - Same as "gnumake"
gnumake clean - To clean temporary object files. Top level
clean will remove all the O.ARCH dirs, not
only those specified in BUILD_ARCHS.
gnumake uninstall - Only available at the top level directory.
Cleans directories created by the install.
gnumake rebuild - Same as "gnumake clean uninstall all"
1.4 "Partial" build commands:
gnumake clean.sun4 - Cleans sun4 binaries in O.sun4 dirs only.
gnumake install.sun4 - Builds sun4 only.
gnumake install.mv167 - Builds mv167 only (a HOST_ARCH build must
be complete before this can be issued).
The complete set of targets now supported are:
action
arch
action.arch
dir
dir.action
dir.arch
dir.action.arch
where:
action can be clean, inc, install, depends, or build
action can also be uninstall or rebuild at top level only
dir is the name of a subdirectory.
arch can be host, cross, sun4, solaris, mv167, ...
Examples are:
gnumake inc - To install include files
gnumake install.host - To build and install EPICS for host arch.
gnumake install.cross - To build and install EPICS for Vx archs.
gnumake clean.sun4 - Cleans sun4 binaries in O.sun4 dirs only.
gnumake install.sun4 - Builds sun4 only.
gnumake install.mv167 - Builds mv167 only (a HOST_ARCH build must
be complete before this can be issued).
NOTES:

View File

@@ -1,7 +1,5 @@
# $Id$
VPATH += .:..
INSTALL_PROD=$(PROD:%=$(INSTALL_BIN)/%)
INSTALL_LIBS=$(LIBNAME:%=$(INSTALL_LIB)/%)
INSTALL_INC=$(INC:%=$(INSTALL_INCLUDE)/%)
@@ -59,7 +57,7 @@ $(TARGETS) $(PROD): $(DEPLIBS)
$(RM) $@
$(LINK.c) -o $@ $< $(LDLIBS)
#$(PROD): $(OBJS) $(DEPLIBS)
#$(PROD): $(OBJS)
# $(RM) $@
# $(LINK.c) -o $@ ${OBJS} $(LDLIBS)
@@ -67,11 +65,19 @@ $(TARGETS) $(PROD): $(DEPLIBS)
$(RM) $@
$(COMPILE.c) $<
%.o: ../%.c
$(RM) $@
$(COMPILE.c) $<
%.o: %.cc
$(RM) $@
$(COMPILE.cc) $<
%.c: %.y
%.o: ../%.cc
$(RM) $@
$(COMPILE.cc) $<
%.c: ../%.y
$(RM) y.tab.c y.tab.h
$(YACC) $(YACCOPT) $<
@if [ -f y.tab.c ]; \
@@ -85,14 +91,14 @@ $(TARGETS) $(PROD): $(DEPLIBS)
/bin/mv y.tab.h $*.h; \
fi
%.c: %.l
%.c: ../%.l
$(RM) lex.yy.c
$(LEX) $(LEXOPT) $<
$(RM) $@
/bin/mv lex.yy.c $@
#state notation language rules
%.c: %.st
#state notation language rule
%.c: ../%.st
@echo "preprocessing $*.st"
@$(RM) $*.i
$(CPP) $(CPPFLAGS) $< $*.i
@@ -109,6 +115,9 @@ $(TARGETS) $(PROD): $(DEPLIBS)
%.db: %.edf
$(E2DB) $(E2SR_SYSFLAGS) $(E2SR_FLAGS) $<
%.db: ../%.edf
$(E2DB) $(E2SR_SYSFLAGS) $(E2SR_FLAGS) $<
%.edf: ../%.sch $(DEPSCHS)
@if [ ! -f cad.rc -a -r ../cad.rc ] ; then ln -s ../cad.rc ; fi
$(SCH2EDIF) $(SCH2EDIF_SYSFLAGS) $(SCH2EDIF_FLAGS) $<
@@ -121,6 +130,13 @@ $(TARGETS) $(PROD): $(DEPLIBS)
$(MANGEN) -s $(<F)
mv $(<F).nr $(<F).1
# Mangen Rule:
%.1:../%
$(RM) $(<F)
$(RM) $(<F).nr
ln -s $<
$(MANGEN) -s $(<F)
mv $(<F).nr $(<F).1
$(LIBNAME): $(LIBOBJS)
@echo Building library $@
@@ -137,6 +153,12 @@ $(INSTALL_BIN)/%: %
@test -d $(INSTALL_BIN) || mkdir $(INSTALL_BIN)
@$(INSTALL_PRODUCT) -m 555 $< $(INSTALL_BIN)
$(INSTALL_BIN)/%: ../%
@echo "Installing $@"
@test -d $(INSTALL_LOCATION_BIN) || mkdir $(INSTALL_LOCATION_BIN)
@test -d $(INSTALL_BIN) || mkdir $(INSTALL_BIN)
@$(INSTALL_PRODUCT) -m 555 $< $(INSTALL_BIN)
$(INSTALL_LIB)/%.a: %.a
@echo "Installing library $@"
@test -d $(INSTALL_LOCATION_LIB) || mkdir $(INSTALL_LOCATION_LIB)
@@ -151,7 +173,12 @@ $(INSTALL_CONFIG)/%: %
@test -d $(INSTALL_CONFIG) || mkdir $(INSTALL_CONFIG)
@$(INSTALL) -m 644 $< $(INSTALL_CONFIG)
$(INSTALL_TCLLIB)/%: %
$(INSTALL_CONFIG)/%: ../%
@echo "Installing $@"
@test -d $(INSTALL_CONFIG) || mkdir $(INSTALL_CONFIG)
@$(INSTALL) -m 644 $< $(INSTALL_CONFIG)
$(INSTALL_TCLLIB)/%: ../%
@echo "Installing Tcl library $@"
@test -d $(INSTALL_LOCATION_LIB) || mkdir $(INSTALL_LOCATION_LIB)
@test -d $(INSTALL_LIB) || mkdir $(INSTALL_LIB)
@@ -175,18 +202,52 @@ $(INSTALL_MAN)/man1/%: %
@test -d $(@D) || mkdir $(@D)
@$(INSTALL) -m 644 $< $(@D)
$(INSTALL_MAN)/man9/% \
$(INSTALL_MAN)/man8/% \
$(INSTALL_MAN)/man7/% \
$(INSTALL_MAN)/man6/% \
$(INSTALL_MAN)/man5/% \
$(INSTALL_MAN)/man4/% \
$(INSTALL_MAN)/man3/% \
$(INSTALL_MAN)/man2/% \
$(INSTALL_MAN)/man1/%: ../%
@echo "Installing $@"
@test -d $(INSTALL_MAN) || mkdir $(INSTALL_MAN)
@test -d $(@D) || mkdir $(@D)
@$(INSTALL) -m 644 $< $(@D)
$(INSTALL_INCLUDE)/%: %
@echo "Installing $@"
@test -d $(INSTALL_INCLUDE) || mkdir $(INSTALL_INCLUDE)
@$(INSTALL) -m 644 $< $(INSTALL_INCLUDE)
$(INSTALL_INCLUDE)/%: ../%
@echo "Installing $@"
@test -d $(INSTALL_INCLUDE) || mkdir $(INSTALL_INCLUDE)
@$(INSTALL) -m 644 $< $(INSTALL_INCLUDE)
$(INSTALL_DOC)/%: %
@echo "Installing $@"
@test -d $(INSTALL_DOC) || mkdir $(INSTALL_DOC)
@$(INSTALL) -m 644 $< $(INSTALL_DOC)
$(INSTALL_DOC)/%: ../%
@echo "Installing $@"
@test -d $(INSTALL_DOC) || mkdir $(INSTALL_DOC)
@$(INSTALL) -m 644 $< $(INSTALL_DOC)
$(INSTALL_TEMPLATES)/$(TEMPLATES_DIR)/%: ../%
@echo "Installing $@"
@test -d $(INSTALL_TEMPLATES) || mkdir $(INSTALL_TEMPLATES)
@test -d $(INSTALL_TEMPLATES)/$(TEMPLATES_DIR) || \
mkdir $(INSTALL_TEMPLATES)/$(TEMPLATES_DIR)
@$(INSTALL) -d -m 644 $< $(INSTALL_TEMPLATES)/$(TEMPLATES_DIR)
$(INSTALL_TEMPLATES)/$(TEMPLATES_DIR)/%: %
@echo "Installing $@"
@test -d $(INSTALL_TEMPLATES) || mkdir $(INSTALL_TEMPLATES)
@test -d $(INSTALL_TEMPLATES)/$(TEMPLATES_DIR) || \
mkdir $(INSTALL_TEMPLATES)/$(TEMPLATES_DIR)
@$(INSTALL) -d -m 644 $< $(INSTALL_TEMPLATES)/$(TEMPLATES_DIR)
.PRECIOUS: %.o %.c

View File

@@ -1,7 +1,5 @@
# $Id$
VPATH += .:..
INCREC +=$(RECTYPES) $(MENUS)
INSTALL_PROD=$(PROD:%=$(INSTALL_BIN)/%)
INSTALL_LIBS=$(LIBNAME:%=$(INSTALL_BIN)/%)
@@ -32,7 +30,7 @@ all:: install
pre_build::
build:: pre_build $(MENUS) $(RECTYPES) $(BPTS)\
$(LIBNAME) $(TARGETS) $(PROD) $(DBDEXPAND)
$(LIBNAME) $(TARGETS) $(PROD)
inc:: $(INSTALL_INC)
@@ -75,11 +73,19 @@ clean::
$(RM) $@
$(COMPILE.c) $<
%.o: ../%.c
$(RM) $@
$(COMPILE.c) $<
%.o: %.cc
$(RM) $@
$(COMPILE.cc) $<
%.c: %.y
%.o: ../%.cc
$(RM) $@
$(COMPILE.cc) $<
%.c: ../%.y
$(RM) y.tab.c y.tab.h
$(YACC) $(YACCOPT) $<
@if [ -f y.tab.c ]; \
@@ -93,14 +99,14 @@ clean::
/bin/mv y.tab.h $*.h; \
fi
%.c: %.l
%.c: ../%.l
$(RM) lex.yy.c
$(LEX) $(LEXOPT) $<
$(RM) $@
/bin/mv lex.yy.c $@
#state notation language rules
%.c: %.st
%.c: ../%.st
@echo "preprocessing $*.st"
@$(RM) $*.i
$(CPP) $(CPPFLAGS) $< $*.i
@@ -117,6 +123,9 @@ clean::
%.db: %.edf
$(E2DB) $(E2SR_SYSFLAGS) $(E2SR_FLAGS) $<
%.db: ../%.edf
$(E2DB) $(E2SR_SYSFLAGS) $(E2SR_FLAGS) $<
%.edf: ../%.sch $(DEPSCHS)
@if [ ! -f cad.rc -a -r ../cad.rc ] ; then ln -s ../cad.rc ; fi
$(SCH2EDIF) $(SCH2EDIF_SYSFLAGS) $(SCH2EDIF_FLAGS) $<
@@ -135,32 +144,43 @@ $(INSTALL_DBD)/%: %
@test -d $(INSTALL_DBD) || mkdir $(INSTALL_DBD)
@$(INSTALL) -m 644 $< $(INSTALL_DBD)
$(INSTALL_DBD)/%: ../%
@echo "Installing $@"
@test -d $(INSTALL_DBD) || mkdir $(INSTALL_DBD)
@$(INSTALL) -m 644 $< $(INSTALL_DBD)
%Record.h: %Record.dbd
$(RM) $@
$(EPICS_BASE)/bin/$(HOST_ARCH)/dbToRecordtypeH \
$(USER_DBDFLAGS) $<
%Record.h: ../%Record.dbd
$(RM) $@
$(EPICS_BASE)/bin/$(HOST_ARCH)/dbToRecordtypeH \
$(USER_DBDFLAGS) $<
menu%.h: menu%.dbd
$(RM) $@
$(EPICS_BASE)/bin/$(HOST_ARCH)/dbToMenuH $<
menu%.h: ../menu%.dbd
$(RM) $@
$(EPICS_BASE)/bin/$(HOST_ARCH)/dbToMenuH $<
bpt%.dbd: bpt%.data
$(RM) $@
$(EPICS_BASE)/bin/$(HOST_ARCH)/makeBpt $<
$(DBDNAME): $(DBDEXPAND)
bpt%.dbd: ../bpt%.data
$(RM) $@
$(EPICS_BASE)/bin/$(HOST_ARCH)/makeBpt $<
$(DBDNAME): ../$(DBDEXPAND)
@echo expanding dbd
@$(RM) $@
$(EPICS_BASE)/bin/$(HOST_ARCH)/dbExpand\
$(USER_DBDFLAGS) $< > $@
%.1:%
$(RM) $(<F)
$(RM) $(<F).nr
ln -s $<
$(MANGEN) -s $(<F)
mv $(<F).nr $(<F).1
$(LIBNAME): $(LIBOBJS)
@echo Building library $@
@$(RM) $@
@@ -172,6 +192,12 @@ $(INSTALL_BIN)/%: %
@test -d $(INSTALL_BIN) || mkdir $(INSTALL_BIN)
@$(INSTALL) -m 555 $< $(INSTALL_BIN)
$(INSTALL_BIN)/%: ../%
@echo "Installing $@"
@test -d $(INSTALL_LOCATION_BIN) || mkdir $(INSTALL_LOCATION_BIN)
@test -d $(INSTALL_BIN) || mkdir $(INSTALL_BIN)
@$(INSTALL) -m 555 $< $(INSTALL_BIN)
$(INSTALL_BIN)/%: $(EPICS_BASE_BIN)/%
@echo "Installing $@"
@test -d $(INSTALL_LOCATION_BIN) || mkdir $(INSTALL_LOCATION_BIN)
@@ -192,16 +218,40 @@ $(INSTALL_MAN)/man1/%: %
@test -d $(@D) || mkdir $(@D)
@$(INSTALL) -m 644 $< $(@D)
$(INSTALL_MAN)/man9/% \
$(INSTALL_MAN)/man8/% \
$(INSTALL_MAN)/man7/% \
$(INSTALL_MAN)/man6/% \
$(INSTALL_MAN)/man5/% \
$(INSTALL_MAN)/man4/% \
$(INSTALL_MAN)/man3/% \
$(INSTALL_MAN)/man2/% \
$(INSTALL_MAN)/man1/%: ../%
@echo "Installing $@"
@test -d $(INSTALL_MAN) || mkdir $(INSTALL_MAN)
@test -d $(@D) || mkdir $(@D)
@$(INSTALL) -m 644 $< $(@D)
$(INSTALL_INCLUDE)/%: %
@echo "Installing $@"
@test -d $(INSTALL_INCLUDE) || mkdir $(INSTALL_INCLUDE)
@$(INSTALL) -m 644 $< $(INSTALL_INCLUDE)
$(INSTALL_INCLUDE)/%: ../%
@echo "Installing $@"
@test -d $(INSTALL_INCLUDE) || mkdir $(INSTALL_INCLUDE)
@$(INSTALL) -m 644 $< $(INSTALL_INCLUDE)
$(INSTALL_DOC)/%: %
@echo "Installing $@"
@test -d $(INSTALL_DOC) || mkdir $(INSTALL_DOC)
@$(INSTALL) -m 644 $< $(INSTALL_DOC)
$(INSTALL_DOC)/%: ../%
@echo "Installing $@"
@test -d $(INSTALL_DOC) || mkdir $(INSTALL_DOC)
@$(INSTALL) -m 644 $< $(INSTALL_DOC)
.PRECIOUS: %.o %.c
.PHONY: all inc depends build install pre-build clean

View File

@@ -3,8 +3,8 @@
#
ARCHS= $(BUILD_ARCHS) host cross
ACTIONS = clean inc install depends
ARCHS += $(BUILD_ARCHS) host cross
ACTIONS += clean inc install depends
dirPart = $(word 1, $(subst $(DIVIDER), ,$@))
actionArchPart = $(subst $(dirPart)$(DIVIDER), ,$@)

View File

@@ -99,6 +99,9 @@
/************************************************************************/
/*
* $Log$
* Revision 1.84 1996/07/10 23:30:09 jhill
* fixed GNU warnings
*
* Revision 1.83 1996/07/09 22:43:29 jhill
* silence gcc warnings and default CLOCKS_PER_SEC if it isnt defined (for sunos4 and gcc)
*
@@ -1544,14 +1547,16 @@ void *usrarg
piiu = chix->piiu;
if(!CA_V41(CA_PROTOCOL_VERSION, piiu->minor_version_number)){
return ECA_NOSUPPORT;
if (piiu) {
if(!CA_V41(CA_PROTOCOL_VERSION, piiu->minor_version_number)){
return ECA_NOSUPPORT;
}
}
#ifdef vxWorks
if (!piiu) {
CACLIENTPUTNOTIFY *ppn;
int size;
unsigned size;
size = dbr_size_n(type,count);
LOCK;

File diff suppressed because it is too large Load Diff

View File

@@ -88,7 +88,7 @@ int local_addr(int s, struct sockaddr_in *plcladdr)
#endif
for ( pifreq = ifconf.ifc_req;
ifconf.ifc_len >= sizeof(*pifreq);
((size_t)ifconf.ifc_len) >= sizeof(*pifreq);
pifreq++, ifconf.ifc_len -= sizeof(*pifreq)) {
status = socket_ioctl(s, SIOCGIFFLAGS, pifreq);

View File

@@ -63,6 +63,9 @@
* datagram socket (and watching for ECONNREFUSED)
*
* $Log$
* Revision 1.36 1996/07/12 00:40:48 jhill
* fixed client disconnect problem under solaris
*
* Revision 1.32.6.1 1996/07/12 00:39:59 jhill
* fixed client disconnect problem under solaris
*
@@ -115,13 +118,13 @@ LOCAL void fanOut(struct sockaddr_in *pFrom, const char *pMsg, unsigned msgSize)
*/
void ca_repeater()
{
int status;
int size;
SOCKET sock;
struct sockaddr_in from;
struct sockaddr_in local;
int from_size = sizeof from;
unsigned short port;
int status;
int size;
SOCKET sock;
struct sockaddr_in from;
struct sockaddr_in local;
int from_size = sizeof from;
unsigned short port;
port = caFetchPortConfig(
&EPICS_CA_REPEATER_PORT,
@@ -186,7 +189,7 @@ void ca_repeater()
* both zero length message and a registration message
* will register a new client
*/
if(size >= sizeof(*pMsg)){
if( ((size_t)size) >= sizeof(*pMsg)){
if(ntohs(pMsg->m_cmmd) == REPEATER_REGISTER){
register_new_client(&local, &from);

View File

@@ -0,0 +1,8 @@
TOP=../../../..
include $(TOP)/config/CONFIG_BASE
include $(TOP)/config/RULES_ARCHS

View File

@@ -0,0 +1,91 @@
CAS = ../../..
TOP = $(CAS)/../..
SRC = $(CAS)/generic
CA = $(CAS)/../ca
IOSRC = $(CAS)/io/bsdSocket
OSSRC = $(CAS)/os/vxWorks
VPATH = $(SRC) $(IOSRC) $(OSSRC)
include $(TOP)/config/CONFIG_BASE
CXXCMPLR = STRICT
USR_INCLUDES = -I$(SRC) -I$(OSSRC) -I$(IOSRC) -I$(CA)\
-I$(TOP)/src/include/os/vxWorks
DEPLIBS_BASE = $(EPICS_BASE_LIB)
SRCS.cc += $(SRC)/caServer.cc
SRCS.cc += $(SRC)/caServerI.cc
SRCS.cc += $(SRC)/casCoreClient.cc
SRCS.cc += $(SRC)/casClient.cc
SRCS.cc += $(SRC)/casDGClient.cc
SRCS.cc += $(SRC)/casStrmClient.cc
SRCS.cc += $(SRC)/casPV.cc
SRCS.cc += $(SRC)/casPVI.cc
SRCS.cc += $(SRC)/casChannel.cc
SRCS.cc += $(SRC)/casChannelI.cc
SRCS.cc += $(SRC)/casClientMon.cc
SRCS.cc += $(SRC)/casChanDelEv.cc
SRCS.cc += $(SRC)/casMsgIO.cc
SRCS.cc += $(SRC)/casAsyncIO.cc
SRCS.cc += $(SRC)/casAsyncIOI.cc
SRCS.cc += $(SRC)/casEventSys.cc
SRCS.cc += $(SRC)/casMonitor.cc
SRCS.cc += $(SRC)/casMonEvent.cc
SRCS.cc += $(SRC)/outBuf.cc
SRCS.cc += $(SRC)/inBuf.cc
SRCS.cc += $(SRC)/casEventMask.cc
SRCS.cc += $(OSSRC)/caServerOS.cc
SRCS.cc += $(OSSRC)/casDGOS.cc
SRCS.cc += $(OSSRC)/casStreamOS.cc
SRCS.cc += $(IOSRC)/caServerIO.cc
SRCS.cc += $(IOSRC)/casDGIO.cc
SRCS.cc += $(IOSRC)/casStreamIO.cc
SRCS.c += $(IOSRC)/sigPipeIgnore.c
LIBOBJS += caServer.o
LIBOBJS += caServerI.o
LIBOBJS += casCoreClient.o
LIBOBJS += casClient.o
LIBOBJS += casDGClient.o
LIBOBJS += casStrmClient.o
LIBOBJS += casPV.o
LIBOBJS += casPVI.o
LIBOBJS += casChannel.o
LIBOBJS += casChannelI.o
LIBOBJS += casClientMon.o
LIBOBJS += casChanDelEv.o
LIBOBJS += casMsgIO.o
LIBOBJS += casAsyncIO.o
LIBOBJS += casAsyncIOI.o
LIBOBJS += casEventSys.o
LIBOBJS += casMonitor.o
LIBOBJS += casMonEvent.o
LIBOBJS += outBuf.o
LIBOBJS += inBuf.o
LIBOBJS += casEventMask.o
LIBOBJS += caServerOS.o
LIBOBJS += casDGOS.o
LIBOBJS += casStreamOS.o
LIBOBJS += caServerIO.o
LIBOBJS += casDGIO.o
LIBOBJS += casStreamIO.o
LIBOBJS += sigPipeIgnore.o
LIBNAME = libcas.o
include $(TOP)/config/RULES.Vx
obj: $(LIBOBJS)
test.o:
clean::
@$(RM) -rf Templates.DB

View File

@@ -11,7 +11,8 @@ include $(TOP)/config/CONFIG_BASE
CXXCMPLR = STRICT
USR_INCLUDES = -I$(SRC) -I$(OSSRC) -I$(IOSRC) -I$(CA)
USR_INCLUDES = -I$(SRC) -I$(OSSRC) -I$(IOSRC) -I$(CA) \
-I$(TOP)/src/include/os/$(T_A)
DEPLIBS_BASE = $(EPICS_BASE_LIB)

View File

@@ -16,12 +16,14 @@ DEPLIBSWOCAS = $(DEPLIBS_BASE)/libca.a $(DEPLIBS_BASE)/libCom.a \
$(DEPLIBS_BASE)/libgdd.a
DEPLIBS = $(DEPLIBS_BASE)/libcas.a $(DEPLIBSWOCAS)
SRCS.cc += ../main.cc
SRCS.cc += ../exServer.cc
SRCS.cc += ../exPV.cc
SRCS.cc += ../exSyncPV.cc
SRCS.cc += ../exAsyncPV.cc
SRCS.cc += ../exChannel.cc
OBJS += main.o
OBJS += exServer.o
OBJS += exPV.o
OBJS += exSyncPV.o
@@ -69,16 +71,21 @@ excas: $(OBJS) $(DEPLIBS)
$(LINK.cc) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS)
#
# fast link (without library build)
# fast link (without waiting for library build)
#
#PURIFY = /remote/lear_local/pure/purify-3.0a-sunos4/purify
nolib: $(OBJS) $(GLOMBOBJ) $(DEPLIBSWOCAS)
$(PURIFY) $(LINK.cc) -o $@ $(OBJS) $(GLOMBOBJ) $(DEPLIBSWOCAS)
$(LINK.cc) -o $@ $(OBJS) $(GLOMBOBJ) $(DEPLIBSWOCAS)
#
# build with purify
#
purify: $(OBJS) $(GLOMBOBJ) $(DEPLIBSWOCAS)
$(PURIFY) -best-effort $(LINK.cc) -o $@ $(OBJS) $(GLOMBOBJ) $(DEPLIBSWOCAS)
clean::
@$(RM) excas
@$(RM) nolib
@$(RM) purify
@$(RM) -rf Templates.DB
@$(RM) core

View File

@@ -350,6 +350,14 @@ caStatus exPV::getUnits(gdd &units)
return S_cas_success;
}
//
// exPV::getEnums()
//
caStatus exPV::getEnums(gdd &)
{
return S_cas_noConvert;
}
//
// exPV::getValue()
//

View File

@@ -7,9 +7,7 @@
// Example EPICS CA server
//
#include <exServer.h>
#include <fdManager.h>
const pvInfo exServer::pvList[] = {
pvInfo (1.0e-1, "jane", 10.0f, 0.0f, excasIoSync),
@@ -18,68 +16,11 @@ const pvInfo exServer::pvList[] = {
pvInfo (2.0, "freddy", 10.0f, -10.0f, excasIoAsync)
};
//
// static data for exServer
//
gddAppFuncTable<exPV> exServer::ft;
//
// main()
//
int main (int argc, const char **argv)
{
osiTime begin(osiTime::getCurrent());
exServer *pCAS;
unsigned debugLevel = 0u;
float executionTime;
aitBool forever = aitTrue;
int i;
pCAS = new exServer(32u,5u,500u);
if (!pCAS) {
return (-1);
}
for (i=1; i<argc; i++) {
if (sscanf(argv[i], "-d %u", &debugLevel)==1) {
continue;
}
if (sscanf(argv[i],"-t %f", &executionTime)==1) {
forever = aitFalse;
continue;
}
printf ("usage: %s -d<debug level> -t<execution time>\n",
argv[0]);
return (1);
}
pCAS->setDebugLevel(debugLevel);
if (forever) {
osiTime delay(1000u,0u);
//
// loop here forever
//
while (aitTrue) {
fileDescriptorManager.process(delay);
}
}
else {
osiTime total(executionTime);
osiTime delay(osiTime::getCurrent() - begin);
//
// loop here untime the specified execution time
// expires
//
while (delay < total) {
fileDescriptorManager.process(delay);
delay = osiTime::getCurrent() - begin;
}
}
return (0);
}
//
// exServer::exServer()
//
@@ -102,6 +43,7 @@ exServer::exServer(unsigned pvMaxNameLength, unsigned pvCountEstimate,
ft.installReadFunc("alarmLowWarning",exPV::getLowLimit);
ft.installReadFunc("units",exPV::getUnits);
ft.installReadFunc("value",exPV::getValue);
ft.installReadFunc("enums",exPV::getEnums);
}
//

View File

@@ -62,6 +62,17 @@ public:
{
}
//
// for use when MSVC++ will not build a defualt copy constructor
// for this class
//
pvInfo (const pvInfo &copyIn) :
scanRate(copyIn.scanRate), name(copyIn.name),
hopr(copyIn.hopr), lopr(copyIn.lopr),
ioType(copyIn.ioType)
{
}
const double getScanRate () const { return this->scanRate; }
const aitString &getName () const { return this->name; }
const double getHopr () const { return this->hopr; }
@@ -149,6 +160,7 @@ public:
gddAppFuncTableStatus getLowLimit(gdd &value);
gddAppFuncTableStatus getUnits(gdd &value);
gddAppFuncTableStatus getValue(gdd &value);
gddAppFuncTableStatus getEnums(gdd &value);
//
//

61
src/cas/example/main.cc Normal file
View File

@@ -0,0 +1,61 @@
#include <exServer.h>
#include <fdManager.h>
//
// main()
//
int main (int argc, const char **argv)
{
osiTime begin(osiTime::getCurrent());
exServer *pCAS;
unsigned debugLevel = 0u;
float executionTime;
aitBool forever = aitTrue;
int i;
pCAS = new exServer(32u,5u,500u);
if (!pCAS) {
return (-1);
}
for (i=1; i<argc; i++) {
if (sscanf(argv[i], "-d %u", &debugLevel)==1) {
continue;
}
if (sscanf(argv[i],"-t %f", &executionTime)==1) {
forever = aitFalse;
continue;
}
printf ("usage: %s -d<debug level> -t<execution time>\n",
argv[0]);
return (1);
}
pCAS->setDebugLevel(debugLevel);
if (forever) {
osiTime delay(1000u,0u);
//
// loop here forever
//
while (aitTrue) {
fileDescriptorManager.process(delay);
}
}
else {
osiTime total(executionTime);
osiTime delay(osiTime::getCurrent() - begin);
//
// loop here untime the specified execution time
// expires
//
while (delay < total) {
fileDescriptorManager.process(delay);
delay = osiTime::getCurrent() - begin;
}
}
delete pCAS;
return (0);
}

View File

@@ -0,0 +1,43 @@
#include <exServer.h>
#include <taskLib.h>
//
// main()
//
int excas (unsigned debugLevel=0u, unsigned delaySec=0)
{
osiTime begin(osiTime::getCurrent());
exServer *pCAS;
pCAS = new exServer(32u,5u,500u);
if (!pCAS) {
return (-1);
}
pCAS->setDebugLevel(debugLevel);
if (delaySec==0u) {
//
// loop here forever
//
while (aitTrue) {
taskDelay(10);
}
}
else {
osiTime total( ((float)delaySec) );
osiTime delay(osiTime::getCurrent() - begin);
//
// loop here untill the specified execution time
// expires
//
while (delay < total) {
taskDelay(10);
delay = osiTime::getCurrent() - begin;
}
}
delete pCAS;
return (0);
}

View File

@@ -1,6 +1,6 @@
this directory contains the generic source for
the EPICS ca server
this directory contains the generic (os and io independent) source for
the EPICS ca server library

View File

@@ -29,6 +29,9 @@
*
* History
* $Log$
* Revision 1.3 1996/08/13 22:56:12 jhill
* added init for mutex class
*
* Revision 1.2 1996/08/05 19:25:17 jhill
* removed unused code
*
@@ -300,10 +303,10 @@ void casVerifyFunc(const char *pFile, unsigned line, const char *pExp)
//
// serverToolDebugFunc()
//
void serverToolDebugFunc(const char *pFile, unsigned line)
void serverToolDebugFunc(const char *pFile, unsigned line, const char *pComment)
{
fprintf(stderr,
"Bad server tool response detected at line %u in \"%s\"\n",
line, pFile);
"Bad server tool response detected at line %u in \"%s\" because \"%s\"\n",
line, pFile, pComment);
}

View File

@@ -29,6 +29,9 @@
*
* History
* $Log$
* Revision 1.2 1996/06/26 21:18:50 jhill
* now matches gdd api revisions
*
* Revision 1.1.1.1 1996/06/20 00:28:14 jhill
* ca server installation
*
@@ -45,7 +48,9 @@
// casAsyncIOI::casAsyncIOI()
//
casAsyncIOI::casAsyncIOI(const casCtx &ctx, casAsyncIO &ioIn, gdd *pDD) :
msg(*ctx.getMsg()), client(*ctx.getClient()),
msg(*ctx.getMsg()),
client(*ctx.getClient()),
asyncIO(ioIn),
pChan(ctx.getChannel()),
pDesc(pDD),
completionStatus(S_cas_internal),
@@ -56,10 +61,7 @@ casAsyncIOI::casAsyncIOI(const casCtx &ctx, casAsyncIO &ioIn, gdd *pDD) :
{
assert (&this->client);
assert (&this->msg);
//
// casAsyncIOI must be a base of casAsyncIO
//
assert (this == (casAsyncIOI *)&ioIn);
assert (&this->asyncIO);
if (this->pChan) {
this->pChan->installAsyncIO(*this);

View File

@@ -29,6 +29,9 @@
*
* History
* $Log$
* Revision 1.1.1.1 1996/06/20 00:28:16 jhill
* ca server installation
*
*
*/
@@ -52,5 +55,13 @@ inline void casAsyncIOI::unlock()
client.unlock();
}
//
// casAsyncIO * casAsyncIOI::operator -> ()
//
inline casAsyncIO * casAsyncIOI::operator -> ()
{
return &this->asyncIO;
}
#endif // casAsyncIOIIL_h

View File

@@ -29,6 +29,9 @@
*
* History
* $Log$
* Revision 1.3 1996/08/13 22:52:31 jhill
* changes for MVC++
*
* Revision 1.2 1996/07/01 19:56:09 jhill
* one last update prior to first release
*
@@ -60,10 +63,10 @@ casChannel::~casChannel()
casPV *casChannel::getPV()
{
casPVI pvi = this->casChannelI::getPVI();
casPVI *pPVI = &this->casChannelI::getPVI();
if (&pvi!=NULL) {
return pvi.intefaceObjectPointer();
if (pPVI!=NULL) {
return pPVI->interfaceObjectPointer();
}
else {
return NULL;

View File

@@ -29,11 +29,15 @@
*
* History
* $Log$
* Revision 1.1.1.1 1996/06/20 00:28:14 jhill
* ca server installation
*
*
*/
#include <server.h>
#include <casEventSysIL.h> // casEventSys inline func
#include <casAsyncIOIIL.h> // casAsyncIOI inline func
#include <casPVIIL.h> // casPVI inline func
@@ -43,14 +47,12 @@
casChannelI::casChannelI(const casCtx &ctx, casChannel &chanAdapter) :
client(* (casStrmClient *) ctx.getClient()),
pv(*ctx.getPV()),
chan(chanAdapter),
cid(ctx.getMsg()->m_cid)
{
assert(&this->client);
assert(&this->pv);
//
// enforce that casChannelI is always a base of casChannel
//
assert(&chanAdapter == (casChannel *) this);
assert(&this->chan);
this->client.installChannel(*this);
}

View File

@@ -29,6 +29,9 @@
*
* History
* $Log$
* Revision 1.2 1996/07/01 19:56:10 jhill
* one last update prior to first release
*
* Revision 1.1.1.1 1996/06/20 00:28:16 jhill
* ca server installation
*
@@ -39,6 +42,14 @@
#ifndef casChannelIIL_h
#define casChannelIIL_h
//
// casChannelI::operator -> ()
//
inline casChannel * casChannelI::operator -> ()
{
return &this->chan;
}
//
// casChannelI::lock()
//
@@ -162,5 +173,6 @@ inline const caResId casChannelI::getSID()
return this->uintId::getId();
}
#endif // casChannelIIL_h

View File

@@ -29,6 +29,9 @@
*
* History
* $Log$
* Revision 1.3 1996/08/13 22:56:13 jhill
* added init for mutex class
*
* Revision 1.2 1996/07/09 22:54:31 jhill
* store msg copy in the ctx
*
@@ -41,6 +44,7 @@
#include <server.h>
#include <casClientIL.h> // inline func for casClient
#include <db_access.h>
VERSIONID(camsgtaskc,"%W% %G%")

View File

@@ -29,6 +29,9 @@
*
* History
* $Log$
* Revision 1.4 1996/08/13 22:54:20 jhill
* fixed little endian problem
*
* Revision 1.3 1996/08/05 19:26:15 jhill
* made os specific code smaller
*
@@ -95,8 +98,7 @@ caStatus casDGClient::searchAction()
// longest PV name then just ignore this request
// (and let the client to try again later)
//
// set correct appl type here !!!!
pCanonicalName = new gddAtomic(0u, aitEnumString, 1u);
pCanonicalName = new gddScalar(gddAppType_name, aitEnumString);
if (!pCanonicalName) {
return S_cas_success;
}
@@ -210,7 +212,7 @@ caStatus casDGClient::searchResponse(casChannelI *nullPtr, const caHdr &msg,
*search_reply = msg;
search_reply->m_postsize = sizeof(*pMinorVersion);
search_reply->m_cid = ~0U;
search_reply->m_type = htons(this->ctx.getServer()->serverPortNumber());
search_reply->m_type = this->ctx.getServer()->serverPortNumber();
search_reply->m_count = 0ul;
/*

View File

@@ -29,6 +29,9 @@
*
* History
* $Log$
* Revision 1.1.1.1 1996/06/20 00:28:16 jhill
* ca server installation
*
*
*/
@@ -91,7 +94,7 @@ inline casEventMask casEventRegistry::maskAllocator()
{
casEventMask evMask;
if (this->allocator>=CHAR_BIT*sizeof(casEventMask::mask)) {
if (this->allocator>=CHAR_BIT*sizeof(evMask.mask)) {
return evMask;
}
evMask.mask = 1u<<(this->allocator++);

View File

@@ -29,6 +29,9 @@
*
* History
* $Log$
* Revision 1.5 1996/07/01 19:56:11 jhill
* one last update prior to first release
*
* Revision 1.4 1996/06/26 23:32:17 jhill
* changed where caProto.h comes from (again)
*
@@ -125,7 +128,7 @@ inline ioBlockedList::~ioBlockedList ()
// ioBlockedList::signal ()
//
// works from a temporary list to avoid problems
// where the virtual function adds ites to the
// where the virtual function adds items to the
// list
//
inline void ioBlockedList::signal ()
@@ -353,14 +356,7 @@ public:
caServer *getCAS();
//
// casAsyncIOI must always be a base for casAsyncIO
// (the constructor assert fails if this isnt the case)
//
casAsyncIO * operator -> ()
{
return (casAsyncIO *) this;
}
inline casAsyncIO * operator -> ();
void setServerDelete()
{
@@ -393,6 +389,7 @@ private:
caHdr const msg;
casCoreClient &client;
casAsyncIO &asyncIO;
casChannelI *pChan; // optional
gdd *pDesc; // optional
caStatus completionStatus;
@@ -461,24 +458,19 @@ public:
return casChanT;
}
//
// casChannelI must always be a base for casPV
// (the constructor assert fails if this isnt the case)
//
casChannel * operator -> ()
{
return (casChannel *) this;
}
inline void lock();
inline void unlock();
inline void clientDestroy();
inline casChannel * operator -> ();
protected:
tsDLList<casMonitor> monitorList;
tsDLList<casAsyncIOI> ioInProgList;
casCoreClient &client;
casPVI &pv;
casChannel &chan;
caResId const cid; // client id
unsigned clientDestroyPending:1;
};
@@ -493,7 +485,6 @@ public:
inline ~casPVListChan();
};
class caServer;
class caServerI;
class casCtx;
class casChannel;
@@ -509,7 +500,7 @@ public:
// The PV name here must be the canonical and unique name
// for the PV in this system
//
casPVI (caServerI &cas, const char * const pName, casPV &pvAdapter);
casPVI (caServerI &cas, const char * const pNameIn, casPV &pvAdapter);
~casPVI();
//
@@ -556,23 +547,12 @@ public:
inline void postEvent (const casEventMask &select, gdd &event);
casPV *intefaceObjectPointer() const
{
return (casPV *) this;
}
inline casPV *interfaceObjectPointer() const;
//
// casPVI must always be a base for casPV
// (the constructor assert fails if this isnt the case)
//
casPV * operator -> () const
{
return intefaceObjectPointer();
}
inline casPV * operator -> () const;
caServer *getExtServer();
//
// bestDBRType()
//
@@ -585,6 +565,7 @@ public:
private:
tsDLList<casPVListChan> chanList;
caServerI &cas;
casPV &pv;
unsigned nMonAttached;
unsigned nIOAttached;
};

View File

@@ -29,6 +29,9 @@
*
* History
* $Log$
* Revision 1.3 1996/07/01 19:56:13 jhill
* one last update prior to first release
*
* Revision 1.2 1996/06/26 21:18:57 jhill
* now matches gdd api revisions
*
@@ -49,16 +52,14 @@
//
casPVI::casPVI(caServerI &casIn, const char * const pNameIn,
casPV &pvAdapterIn) :
cas(casIn),
stringId(pNameIn),
cas(casIn),
pv(pvAdapterIn),
nMonAttached(0u),
nIOAttached(0u)
{
assert(&cas);
//
// casPVI must always be a base of casPV
//
assert(&pvAdapterIn == (casPV *)this);
assert(&this->cas);
assert(&this->pv);
this->cas.installPV(*this);
}
@@ -108,22 +109,22 @@ caStatus casPVI::verifyPVName(gdd &name)
//
gddStatus = name.reference();
if (gddStatus) {
serverToolDebug();
serverToolDebug("GDD PV name must not be \"no ref\"");
return S_cas_badPVName;
}
gddStatus = name.unreference();
if (gddStatus) {
serverToolDebug();
serverToolDebug("corruption expected");
return S_cas_badPVName;
}
if (name.primitiveType() != aitEnumString) {
serverToolDebug();
serverToolDebug("GDD PV name must be stored as an aitString");
return S_cas_badPVName;
}
if (name.dimension() != 1u) {
serverToolDebug();
if (name.dimension() != 0u) {
serverToolDebug("GDD Dimension must be zero (gddScaler)");
return S_cas_badPVName;
}

View File

@@ -29,6 +29,9 @@
*
* History
* $Log$
* Revision 1.4 1996/07/01 19:56:13 jhill
* one last update prior to first release
*
* Revision 1.3 1996/06/26 21:18:58 jhill
* now matches gdd api revisions
*
@@ -47,6 +50,26 @@
#include <dbMapper.h>
//
// casPVI::interfaceObjectPointer()
//
// casPVI must always be a base for casPV
// (the constructor assert fails if this isnt the case)
//
inline casPV *casPVI::interfaceObjectPointer() const
{
return &this->pv;
}
//
// casPVI::operator -> ()
//
casPV * casPVI::operator -> () const
{
return interfaceObjectPointer();
}
//
// casPVI::lock()
//
@@ -88,8 +111,7 @@ inline void casPVI::removeChannel(casPVListChan &chan)
//
inline aitBool casPVI::okToBeginNewIO() const
{
if (this->nIOAttached >= (*this)->maxSimultAsyncOps())
{
if (this->nIOAttached >= (*this)->maxSimultAsyncOps()) {
return aitFalse;
}
else {
@@ -178,7 +200,6 @@ inline void casPVI::postEvent (const casEventMask &select, gdd &event)
}
}
#endif // casPVIIL_h

View File

@@ -29,6 +29,9 @@
*
* History
* $Log$
* Revision 1.8 1996/08/05 23:22:57 jhill
* gddScaler => gddScalar
*
* Revision 1.7 1996/08/05 19:26:51 jhill
* doc
*
@@ -116,8 +119,7 @@ inline caStatus casStrmClient::createChannel (const char *pName)
int gddStatus;
gdd *pCanonicalName;
// set correct appl type here !!!!
pCanonicalName = new gddAtomic(0u, aitEnumString, 1u);
pCanonicalName = new gddScalar(gddAppType_name, aitEnumString);
if (!pCanonicalName) {
return S_cas_noMemory;
}
@@ -1058,6 +1060,11 @@ caStatus casStrmClient::eventAddAction ()
return S_cas_success;
}
//
// place monitor mask in correct byte order
//
pMonInfo->m_mask = ntohs (pMonInfo->m_mask);
if (pMonInfo->m_mask&DBE_VALUE) {
mask |= this->getCAS().getAdapter()->valueEventMask;
}
@@ -1566,15 +1573,15 @@ caStatus createDBRDD (unsigned dbrType, aitIndex dbrCount, gdd *&pDescRet)
pVal = pCont->getDD(valIndex);
assert (pVal);
gddStatus = pVal->setBound (0, 0u, dbrCount);
assert (gddStatus==0)
assert (gddStatus==0);
}
else if (pDescRet->isAtomic()) {
gddAtomic *pAtomic = (gddAtomic *) pDescRet;
gddStatus = pAtomic->setBound(0, 0u, dbrCount);
assert (gddStatus==0)
assert (gddStatus==0);
}
else {
assert(dbrCount==1u);
assert (dbrCount==1u);
}
}
@@ -1683,6 +1690,7 @@ casPVI *caServerI::createPV (gdd &name)
{
casPVI *pPVI;
caStatus status;
aitString *pNameStr;
//
// dont proceed unless its a valid PV name
@@ -1700,15 +1708,15 @@ casPVI *caServerI::createPV (gdd &name)
// way currently to test) it will prove fatal
// to the server
//
aitString aitStr(name);
stringId id (aitStr.string());
name.getRef(pNameStr);
stringId id (pNameStr->string());
this->lock ();
pPVI = this->stringResTbl.lookup (id);
if (!pPVI) {
casPV *pPV;
pPV = (*this)->createPV (this->ctx, aitStr.string());
pPV = (*this)->createPV (this->ctx, pNameStr->string());
if (pPV) {
pPVI = (casPVI *) pPV;
}

View File

@@ -30,6 +30,9 @@
* Modification Log:
* -----------------
* $Log$
* Revision 1.5 1996/08/13 22:54:42 jhill
* doc
*
* Revision 1.4 1996/07/01 19:56:15 jhill
* one last update prior to first release
*
@@ -252,6 +255,8 @@ public:
}
};
class caServerI;
//
// caServer - Channel Access Server API Class
//
@@ -271,10 +276,6 @@ public:
unsigned maxSimultaneousIO=1u);
virtual ~caServer();
//
// Need VF that returns pointer to derived type ?
//
//caStatus enableClients ();
//caStatus disableClients ();
@@ -542,5 +543,5 @@ public:
casPV *getPV();
};
#endif /* ifdef includecasdefh (this must be the last line in this file) */
#endif // ifdef includecasdefh (this must be the last line in this file)

View File

@@ -29,6 +29,9 @@
*
* History
* $Log$
* Revision 1.2 1996/08/13 22:53:59 jhill
* fixed little endian problem
*
* Revision 1.1.1.1 1996/06/20 00:28:15 jhill
* ca server installation
*
@@ -172,6 +175,7 @@ void outBuf::commitMsg ()
*/
mp->m_cmmd = htons (mp->m_cmmd);
mp->m_postsize = htons (mp->m_postsize);
mp->m_type = htons (mp->m_type);
mp->m_count = htons (mp->m_count);
mp->m_cid = htonl (mp->m_cid);
mp->m_available = htonl (mp->m_available);

View File

@@ -29,6 +29,9 @@
*
* History
* $Log$
* Revision 1.9 1996/08/13 22:56:14 jhill
* added init for mutex class
*
* Revision 1.8 1996/08/05 23:22:58 jhill
* gddScaler => gddScalar
*
@@ -75,21 +78,13 @@ HDRVERSIONID(serverh, "%W% %G%")
//
// ANSI C
//
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <limits.h>
//
// EPICS
//
#define epicsAssertAuthor "Jeff Hill johill@lanl.gov"
#include <epicsAssert.h>
#include <db_access.h>
//
// CA
@@ -99,20 +94,13 @@ HDRVERSIONID(serverh, "%W% %G%")
#include <casdef.h>
#include <osiTime.h>
//
// gdd
//
#if 0
#include <dbMapper.h>
#include <gddApps.h>
#endif
//
// CAS
//
void casVerifyFunc(const char *pFile, unsigned line, const char *pExp);
void serverToolDebugFunc(const char *pFile, unsigned line);
#define serverToolDebug() {serverToolDebugFunc(__FILE__, __LINE__); }
void serverToolDebugFunc(const char *pFile, unsigned line, const char *pComment);
#define serverToolDebug(COMMENT) \
{serverToolDebugFunc(__FILE__, __LINE__, COMMENT); }
#define casVerify(EXP) {if ((EXP)==0) casVerifyFunc(__FILE__, __LINE__, #EXP); }
caStatus createDBRDD(unsigned dbrType, aitIndex dbrCount, gdd *&pDescRet);
caStatus copyBetweenDD(gdd &dest, gdd &src);
@@ -893,10 +881,8 @@ private:
class casClientMon;
//
// caServerI
//
class caServerI : public caServerOS, public caServerIO,
class caServerI :
public caServerOS, public caServerIO,
public osiMutex, public ioBlockedList,
private uintResTable<casRes>,
public casEventRegistry {
@@ -983,7 +969,7 @@ public:
return &this->adapter;
}
uintResTable<casRes> &getResTable() {return *this;}
//uintResTable<casRes> &getResTable() {return *this;}
void installItem(casRes &res)
{

View File

@@ -276,7 +276,10 @@ xSendStatus casDGIO::osdSend(const char *pBuf, bufSizeT size,
return xSendOK;
}
status = sendto(this->sock, pBuf, size, 0,
//
// (char *) cast below is for brain dead wrs prototype
//
status = sendto(this->sock, (char *) pBuf, size, 0,
&this->lastRecvAddr.sa,
sizeof(this->lastRecvAddr.sa));
if (status>0) {

View File

@@ -7,6 +7,9 @@
// Some BSD calls have crept in here
//
// $Log$
// Revision 1.3 1996/08/13 23:00:29 jhill
// removed include of netdb.h
//
// Revision 1.2 1996/07/24 22:03:36 jhill
// fixed net proto for gnu compiler
//
@@ -19,43 +22,13 @@
#define includeCASIODH
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#ifndef SUNOS4 // func proto do not have args for C++ (under sunos4)
#include <arpa/inet.h>
#endif
#ifdef __cplusplus
}
#endif
#include <bsdProto.h>
typedef int SOCKET;
#define SOCKERRNO errno
#define socket_close(S) close(S)
#define socket_ioctl(A,B,C) ioctl(A,B,C)
#include <osiSock.h>
// ca
#include <addrList.h>
void hostNameFromIPAddr (const caAddr *pAddr,
char *pBuf, unsigned bufSize);
#if 0
//
// assuming al posix machines are IEEE float will be wrong
//
#define ntohf(A) (A)
#define ntohd(A) (A)
#define htonf(A) (A)
#define htond(A) (A)
#endif
class caServerIO {
public:

View File

@@ -7,6 +7,9 @@
// Some BSD calls have crept in here
//
// $Log$
// Revision 1.2 1996/08/13 22:58:15 jhill
// fdMgr.h => fdmanager.h
//
// Revision 1.1.1.1 1996/06/20 00:28:06 jhill
// ca server installation
//
@@ -24,7 +27,14 @@ extern "C" {
// for htons() etc
//
# include <netinet/in.h>
//
// g++ 2.7.2 does not fix this file under sunos4 so I
// have provided the prototype elsewhere (in osiSock.h for now)
//
#if !(defined(SUNOS4) && defined(__GNUC__))
# include <netdb.h>
#endif
} // extern "C"
#include <osiMutex.h>

View File

@@ -2,6 +2,7 @@
WORK IN PROGRESS
this directory contains the vxWorks os dependent source for
the EPICS ca server
the EPICS ca server. This is a multi-threaded port of the
server.

View File

@@ -0,0 +1,124 @@
/*
*
* caServerOS.c
* $Id$
*
*
* $Log$
* Revision 1.1.1.1 1996/06/20 00:28:06 jhill
* ca server installation
*
*
*/
#include <taskLib.h>
#include <task_params.h>
//
// CA server
//
#include <server.h>
//
// aServerOS::operator -> ()
//
inline caServerI * caServerOS::operator -> ()
{
return &this->cas;
}
//
// casBeaconTimer::expire()
//
void casBeaconTimer::expire()
{
os->sendBeacon ();
}
//
// casBeaconTimer::again()
//
osiBool casBeaconTimer::again()
{
return osiTrue;
}
//
// casBeaconTimer::delay()
//
const osiTime casBeaconTimer::delay()
{
return os->getBeaconPeriod();
}
//
// caServerOS::init()
//
caStatus caServerOS::init()
{
this->pBTmr = new casBeaconTimer((*this)->getBeaconPeriod(), *this);
if (!this->pBTmr) {
ca_printf("CAS: Unable to start server beacon\n");
return S_cas_noMemory;
}
//
// WRS still passes pointers in ints
//
assert (sizeof(int)==sizeof(&this->cas));
this->tid = taskSpawn (
REQ_SRVR_NAME,
REQ_SRVR_PRI,
REQ_SRVR_OPT,
REQ_SRVR_STACK,
(FUNCPTR) caServerEntry, // get your act together WRS
(int) &this->cas, // get your act together WRS
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL);
if (this->tid==ERROR) {
return S_cas_noMemory;
}
return S_cas_success;
}
//
// caServerOS::~caServerOS()
//
caServerOS::~caServerOS()
{
if (this->pBTmr) {
delete this->pBTmr;
}
if (taskIdVerify(this->tid)==OK)
{
taskDelete(this->tid);
}
}
//
// caServer()
//
void caServer(caServerI *pCAS)
{
//
// forever
//
while (TRUE) {
pCAS->connectCB();
printf("process timer q here?\n");
}
}

View File

@@ -0,0 +1,77 @@
class casStreamEvWakeup;
//
// casStreamOS
//
class casStreamOS : public casStrmClient {
friend int casStrmServer (casStreamOS *);
friend int casStrmEvent (casStreamOS *);
public:
casStreamOS(caServerI &, casMsgIO &);
caStatus init();
~casStreamOS();
//
// process any incomming messages
//
casProcCond processInput();
caStatus start();
void sendBlockSignal();
void ioBlockedSignal();
void eventSignal();
void eventFlush();
void show(unsigned level);
private:
SEM_ID eventSignalSem;
int clientTId;
int eventTId;
};
//
// vxWorks task entry
//
int casStrmServer (casStreamOS *);
int casStrmEvent (casStreamOS *);
class casDGEvWakeup;
//
// casDGOS
//
class casDGOS : public casDGClient {
friend int casDGServer (casDGOS *);
friend int casDGEvent (casDGOS *);
public:
casDGOS(caServerI &cas);
caStatus init();
~casDGOS();
//
// process any incomming messages
//
casProcCond processInput();
caStatus start();
void sendBlockSignal() {}
void eventSignal();
void eventFlush();
void show(unsigned level);
private:
SEM_ID eventSignalSem;
int clientTId;
int eventTId;
};
//
// vxWorks task entry
//
int casDGServer (casDGOS *);
int casDGEvent (casDGOS *);

View File

@@ -0,0 +1,211 @@
/*
*
* casDGOS.c
* $Id$
*
*
* $Log$
* Revision 1.1.1.1 1996/06/20 00:28:06 jhill
* ca server installation
*
*
*/
//
// CA server
//
#include <taskLib.h> // vxWorks
#include <server.h>
#include <casClientIL.h> // casClient inline func
#include <task_params.h> // EPICS task priorities
//
// casDGOS::eventSignal()
//
void casDGOS::eventSignal()
{
STATUS st;
st = semGive(this->eventSignalSem);
assert (st==OK);
}
//
// casDGOS::eventFlush()
//
void casDGOS::eventFlush()
{
this->flush();
}
//
// casDGOS::casDGOS()
//
casDGOS::casDGOS(caServerI &cas) :
eventSignalSem(NULL),
casDGClient(cas),
clientTId(ERROR),
eventTId(ERROR)
{
}
//
// casDGOS::init()
//
caStatus casDGOS::init()
{
caStatus status;
this->eventSignalSem = semBCreate(SEM_Q_PRIORITY, SEM_EMPTY);
if (this->eventSignalSem == NULL) {
return S_cas_noMemory;
}
//
// init the base classes
//
status = this->casDGClient::init();
return status;
}
//
// casDGOS::~casDGOS()
//
casDGOS::~casDGOS()
{
if (taskIdVerify(this->clientTId)==OK) {
taskDelete(this->clientTId);
}
if (taskIdVerify(this->eventTId)==OK) {
taskDelete(this->eventTId);
}
if (this->eventSignalSem) {
semDelete(this->eventSignalSem);
}
}
//
// casDGOS::show()
//
void casDGOS::show(unsigned level)
{
this->casDGClient::show(level);
printf ("casDGOS at %x\n", (unsigned) this);
if (taskIdVerify(this->clientTId) == OK) {
taskShow(this->clientTId, level);
}
if (taskIdVerify(this->eventTId) == OK) {
taskShow(this->eventTId, level);
}
if (this->eventSignalSem) {
semShow(this->eventSignalSem, level);
}
}
/*
* casClientStart ()
*/
caStatus casDGOS::start()
{
//
// no (void *) vxWorks task arg
//
assert (sizeof(int) >= sizeof(this));
this->clientTId = taskSpawn(
CAST_SRVR_NAME,
CAST_SRVR_PRI,
CAST_SRVR_OPT,
CAST_SRVR_STACK,
(FUNCPTR) casDGServer, // get your act together wrs
(int) this, // get your act together wrs
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL);
if (this->clientTId==ERROR) {
return S_cas_noMemory;
}
this->eventTId = taskSpawn(
CA_EVENT_NAME,
CA_CLIENT_PRI,
CA_CLIENT_OPT,
CAST_SRVR_STACK,
(FUNCPTR) casDGEvent, // get your act together wrs
(int) this, // get your act together wrs
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL);
if (this->eventTId==ERROR) {
return S_cas_noMemory;
}
return S_cas_success;
}
/*
* casDGOS::processInput ()
* - a noop
*/
casProcCond casDGOS::processInput ()
{
return casProcOk;
}
//
// casDGServer()
//
int casDGServer (casDGOS *pDGOS)
{
caStatus status;
//
// block for the next DG until the connection closes
//
while (TRUE) {
status = pDGOS->processInput();
if (status) {
errMessage(status, "casDGServer (casDGOS *pDGOS)");
}
}
}
//
// casDGEvent()
//
int casDGEvent (casDGOS *pDGOS)
{
STATUS status;
casProcCond cond;
//
// Wait for event queue entry
//
while (TRUE) {
status = semTake(pDGOS->eventSignalSem, WAIT_FOREVER);
assert (status!=OK);
cond = pDGOS->casEventSys::process();
if (cond != casProcOk) {
printf("DG event sys process failed\n");
}
}
}

View File

@@ -0,0 +1,92 @@
//
// $Id$
//
// casOSD.h - Channel Access Server OS Dependent for posix
//
//
// Some BSD calls have crept in here
//
// $Log$
// Revision 1.1.1.1 1996/06/20 00:28:06 jhill
// ca server installation
//
//
#ifndef includeCASOSDH
#define includeCASOSDH
#include <unistd.h>
#include <errno.h>
extern "C" {
//
// for htons() etc
//
# include <netinet/in.h>
# include <ioLib.h>
} // extern "C"
#include <osiMutex.h>
#include <osiTimer.h>
class caServerI;
class caServerOS;
//
// casBeaconTimer
//
class casBeaconTimer : public osiTimer {
public:
casBeaconTimer (const osiTime &delay, caServerOS &osIn) :
os (osIn), osiTimer(delay) {}
void expire();
const osiTime delay();
osiBool again();
const char *name()
{
return "casBeaconTimer";
}
private:
caServerOS &os;
int taskId;
};
class casServerReg;
class caServerOS;
//
// vxWorks task entry
//
int caServerEntry(caServerI *pCAS);
//
// caServerOS
//
class caServerOS {
friend class casServerReg;
friend int caServerEntry(caServerOS *pOS);
public:
caServerOS (caServerI &casIn) :
cas (casIn), pBTmr (NULL), tid(ERROR) {}
caStatus init ();
~caServerOS ();
//caStatus start ();
inline caServerI * operator -> ();
//int getFD();
private:
caServerI &cas;
casBeaconTimer *pBTmr;
int tid;
};
// no additions below this line
#endif // includeCASOSDH

View File

@@ -0,0 +1,280 @@
//
// casStreamOS.cc
// $Id$
//
//
// $Log$
// Revision 1.1.1.1 1996/06/20 00:28:06 jhill
// ca server installation
//
//
//
//
// CA server
//
#include<server.h>
#include <casClientIL.h> // casClient inline func
#include <task_params.h> // EPICS task priorities
//
// casStreamOS::ioBlockedSignal()
//
void casStreamOS::ioBlockedSignal()
{
printf("in casStreamOS::ioBlockedSignal()\n");
}
//
// casStreamOS::eventSignal()
//
void casStreamOS::eventSignal()
{
STATUS st;
st = semGive(this->eventSignalSem);
assert (st==OK);
}
//
// casStreamOS::eventFlush()
//
void casStreamOS::eventFlush()
{
this->flush();
}
//
// casStreamOS::casStreamOS()
//
casStreamOS::casStreamOS(caServerI &cas, casMsgIO &ioIn) :
casStrmClient(cas, ioIn),
eventSignalSem(NULL),
clientTId(NULL),
eventTId(NULL)
{
}
//
// casStreamOS::init()
//
caStatus casStreamOS::init()
{
caStatus status;
this->eventSignalSem = semBCreate(SEM_Q_PRIORITY, SEM_EMPTY);
if (this->eventSignalSem == NULL) {
return S_cas_noMemory;
}
//
// init the base classes
//
status = this->casStrmClient::init();
if (status) {
return status;
}
return S_cas_success;
}
//
// casStreamOS::~casStreamOS()
//
casStreamOS::~casStreamOS()
{
//
// attempt to flush out any remaining messages
//
this->flush();
if (taskIdVerify(this->clientTId)==OK &&
this->clientTId != taskIdSelf()) {
taskDelete(this->clientTId);
}
if (taskIdVerify(this->eventTId)==OK &&
this->eventTId != taskIdSelf()) {
taskDelete(this->eventTId);
}
if (this->eventSignalSem) {
semDelete(this->eventSignalSem);
}
}
//
// casStreamOS::show()
//
void casStreamOS::show(unsigned level)
{
this->casStrmClient::show(level);
printf("casStreamOS at %x\n", (unsigned) this);
if (taskIdVerify(this->clientTId)==OK) {
taskShow(this->clientTId, level);
}
if (taskIdVerify(this->eventTId)==OK) {
taskShow(this->eventTId, level);
}
if (this->eventSignalSem) {
semShow(this->eventSignalSem, level);
}
}
//
// casClientStart ()
//
caStatus casStreamOS::start()
{
//
// no (void *) vxWorks task arg
//
assert (sizeof(int) >= sizeof(this));
this->clientTId = taskSpawn(
CA_CLIENT_NAME,
CA_CLIENT_PRI,
CA_CLIENT_OPT,
CA_CLIENT_STACK,
(FUNCPTR) casStrmServer, // get your act together wrs
(int) this, // get your act together wrs
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL);
if (this->clientTId==ERROR) {
return S_cas_noMemory;
}
this->eventTId = taskSpawn(
CA_EVENT_NAME,
CA_CLIENT_PRI,
CA_CLIENT_OPT,
CA_CLIENT_STACK,
(FUNCPTR) casStrmEvent, // get your act together wrs
(int) this, // get your act together wrs
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL);
if (this->eventTId==ERROR) {
return S_cas_noMemory;
}
return S_cas_success;
}
//
// casStreamOS::sendBlockSignal()
//
void casStreamOS::sendBlockSignal()
{
printf("in casStreamOS::sendBlockSignal()\n");
}
//
// casStreamOS::processInput()
//
casProcCond casStreamOS::processInput()
{
caStatus status;
# ifdef DEBUG
printf(
"Resp bytes to send=%d, Req bytes pending %d\n",
this->outBuf::bytesPresent(),
this->inBuf::bytesPresent());
# endif
status = this->processMsg();
switch (status) {
case S_cas_partialMessage:
case S_cas_ioBlocked:
case S_cas_success:
return casProcOk;
default:
errMessage (status,
"unexpected error processing client's input");
return casProcDisconnect;
}
}
//
// casStrmServer()
//
int casStrmServer (casStreamOS *pStrmOS)
{
casFillCondition fillCond;
casProcCond procCond;
caStatus status;
//
// block for the next DG until the connection closes
//
while (TRUE) {
//
// copy in new messages
//
fillCond = pStrmOS->fill();
procCond = pStrmOS->processInput();
if (fillCond == casFillDisconnect ||
procCond == casProcDisconnect) {
delete pStrmOS;
//
// NO CODE HERE
// (see delete above)
//
return OK;
}
else if (pStrmOS->inBuf::full()==aitTrue) {
//
// If there isnt any space then temporarily
// stop calling this routine until problem is resolved
// either by:
// (1) sending or
// (2) a blocked IO op unblocks
//
delete pStrmOS;
//
// NO CODE HERE
// (see delete above)
//
return OK;
}
}
}
//
// casStrmEvent()
//
int casStrmEvent(casStreamOS *pStrmOS)
{
STATUS status;
casProcCond cond;
//
// Wait for event queue entry
//
while (TRUE) {
status = semTake(pStrmOS->eventSignalSem, WAIT_FOREVER);
assert (status!=OK);
cond = pStrmOS->casEventSys::process();
if (cond != casProcOk) {
printf("Stream event sys process failed\n");
}
}
}

View File

@@ -0,0 +1,51 @@
//
// osiMutex - OS independent mutex
// (vxWorks version)
//
#include <semLib.h>
#include <assert.h>
class osiMutex {
public:
osiMutex()
{
mutex = NULL;
}
//
// constructor that returns status
// (since g++ does not have exceptions)
//
int init ()
{
this->mutex = semMCreate(SEM_Q_PRIORITY|SEM_INVERSION_SAFE);
if (this->mutex==NULL)
{
return -1;
}
return 0;
}
~osiMutex()
{
STATUS s;
s = semDelete (this->mutex);
assert (s==OK);
}
void lock()
{
STATUS s;
assert(this->mutex);
s = semTake (this->mutex, WAIT_FOREVER);
assert (s==OK);
}
void unlock()
{
STATUS s;
s = semGive (this->mutex);
assert (s==OK);
}
private:
SEM_ID mutex;
};

View File

@@ -1,659 +0,0 @@
/*
*
* vxWorks_depen.c
* %W% %G%
*
* vxWorks dependent routines for the CA server
*
*
*/
#include <server.h>
#include <inetLib.h>
VERSIONID(vxWorks_depenc,"%W% %G%")
#define MUTEX_SEM_OPTIONS \
(SEM_Q_PRIORITY | SEM_DELETE_SAFE | SEM_INVERSION_SAFE)
LOCAL int event_task(
struct event_user *evuser,
void (*init_func)(int arg),
int init_func_arg
);
LOCAL void osDepenTimerCB(void *pciu);
LOCAL void osDepenSendCB(void *pClient);
int caServerTask(struct rsrv *pRsrv);
LOCAL int caMaxFreeBlockPoll(void);
size_t caMaxFreeBlock;
###### no event flush currently (only needed in multi thread env) ####
status = caeqAddFlushEvent (client->evuser, XXXX, client);
assert (status==OK);
/*
* caGetElapsedTime()
*/
caStatus caGetElapsedTime(caElapsedTimeVal *pElapsed)
{
ULONG ticks;
ULONG rate;
ticks = tickGet();
rate = sysClkRateGet();
pElapsed->tv_sec = ticks * rate;
pElapsed->tv_usec = ((ticks % rate)*CAServerUSecInSec)/rate;
return S_cas_success;
}
/*
* caOutOfMemory()
*/
int caOutOfMemory(void)
{
int status;
static int pollTaskStarted;
if(!pollTaskStarted){
caMaxFreeBlock = memFindMax();
status = taskSpawn(
MAXFREEBLOCKTASKNAME,
MAXFREEBLOCKTASKPRI,
MAXFREEBLOCKTASKOPT,
MAXFREEBLOCKTASKSTACK,
caMaxFreeBlockPoll,
0,0,0,0,0,0,0,0,0,0);
if(status>=0){
pollTaskStarted = TRUE;
}
}
return (caMaxFreeBlock<MAX_BLOCK_THRESHOLD);
}
/*
* caMaxFreeBlockPoll()
*/
LOCAL int caMaxFreeBlockPoll(void)
{
while(TRUE){
caMaxFreeBlock = memFindMax();
taskDelay(MAXFREEBLOCKPOLL*sysClkRateGet());
}
}
/*
* casPutCBStartTimer()
*/
caStatus casPutCBStartTimer(
casChanInUse *pciu,
unsigned timeOutSec
)
{
struct client *pClient = pciu->client;
caserver *pRsrv = pClient->cc.pRsrv;
struct timeval tv;
if(pClient->cc.osSpecific.pPutCBAlarm){
tv.tv_sec = timeOutSec;
tv.tv_usec = 0;
pClient->cc.osSpecific.pPutCBAlarm
= fdmgr_add_timeout(
pRsrv->osSpecific.pfdctx,
&tv,
osDepenTimerCB,
pciu);
if(!pClient->cc.osSpecific.pPutCBAlarm){
return S_cas_noMemory;
}
}
return S_cas_success;
}
/*
* osDepenTimerCB()
*/
LOCAL void osDepenTimerCB(void *pParam)
{
casChanInUse *pciu = (casChanInUse *)pParam;
pciu->client->cc.osSpecific.pPutCBAlarm = NULL;
casPutCBTimer(pciu);
}
/*
* casPutCBCancelTimer()
*/
void casPutCBCancelTimer(struct client *pClient)
{
caserver *pRsrv = pClient->cc.pRsrv;
int status;
if(pClient->cc.osSpecific.pPutCBAlarm){
status = fdmgr_clear_timeout(
pRsrv->osSpecific.pfdctx,
pClient->cc.osSpecific.pPutCBAlarm);
assert(status==0);
pClient->cc.osSpecific.pPutCBAlarm = NULL;
}
}
/*
* casDisableSocketRecvIOCallback()
*/
caStatus casDisableSocketRecvIOCallback(struct client *pClient)
{
int status;
if(pClient->cc.osSpecific.sockRecvIOCallbackEnabled){
status = fdmgr_clear_callback(
pClient->cc.pRsrv->osSpecific.pfdctx,
pClient->cc.sock,
fdi_read);
assert(status==0);
pClient->cc.osSpecific.sockRecvIOCallbackEnabled = FALSE;
}
return S_cas_success;
}
/*
* casEnableSocketRecvIOCallback()
*/
caStatus casEnableSocketRecvIOCallback(struct client *pClient)
{
caserver *pRsrv = pClient->cc.pRsrv;
int status;
if(!pClient->cc.osSpecific.sockRecvIOCallbackEnabled){
status = fdmgr_add_callback(
pRsrv->osSpecific.pfdctx,
pClient->cc.sock,
fdi_read,
pClient->cc.pCB,
pClient);
if(status){
return S_cas_noMemory;
}
pClient->cc.osSpecific.sockRecvIOCallbackEnabled = TRUE;
}
return S_cas_success;
}
/*
* casWaitForIO ()
*/
caStatus casWaitForIO (struct rsrv *pRsrv, caTime *pDelay)
{
struct timeval tv;
tv.tv_sec = caTime->sec;
tv.tv_usec = caTime->nsec / NSecPerUsec;
status = fdmgr_pend_event(pRsrv->osSpecific.pfdctx, &tv);
if (status) {
return S_cas_internal;
}
return S_cas_success;
}
/*
* casArmSocketSendIOCallback()
*/
caStatus casArmSocketSendIOCallback(struct client *pClient)
{
caserver *pRsrv = pClient->cc.pRsrv;
int status;
if(!pClient->cc.osSpecific.sockSendIOCallbackEnabled){
status = fdmgr_add_callback(
pRsrv->osSpecific.pfdctx,
pClient->cc.sock,
fdi_write,
osDepenSendCB,
pClient);
if(status){
return S_cas_noMemory;
}
pClient->cc.osSpecific.sockSendIOCallbackEnabled = TRUE;
}
return S_cas_success;
}
/*
* casCancelSocketSendIOCallback()
*/
caStatus casCancelSocketSendIOCallback(struct client *pClient)
{
caserver *pRsrv = pClient->cc.pRsrv;
int status;
if(pClient->cc.osSpecific.sockSendIOCallbackEnabled){
status = fdmgr_clear_callback(
pRsrv->osSpecific.pfdctx,
pClient->cc.sock,
fdi_write);
assert(status==0);
pClient->cc.osSpecific.sockSendIOCallbackEnabled = FALSE;
}
return S_cas_success;
}
/*
* osDepenSendCB()
*/
LOCAL void osDepenSendCB(void *pParam)
{
struct client *pClient = (struct client *) pParam;
pClient->cc.osSpecific.sockSendIOCallbackEnabled = FALSE;
(*pClient->sendHandler)(pClient);
}
/*
* casOSSpecificDelete()
*/
void casOSSpecificDelete(struct rsrv *pRsrv)
{
int status;
if(taskIdVerify(pRsrv->osSpecific.selectTask) == OK){
taskwdRemove(taskDelete(pRsrv->osSpecific.selectTask));
taskDelete(pRsrv->osSpecific.selectTask);
}
if(pRsrv->osSpecific.clientQLock){
status = semDelete(pRsrv->osSpecific.clientQLock);
assert(status==OK);
}
if(pRsrv->osSpecific.freeChanQLock){
status = semDelete(pRsrv->osSpecific.freeChanQLock);
assert(status==OK);
}
if(pRsrv->osSpecific.freeEventQLock){
status = semDelete(pRsrv->osSpecific.freeEventQLock);
assert(status==OK);
}
if(pRsrv->osSpecific.pvQLock){
status = semDelete(pRsrv->osSpecific.pvQLock);
assert(status==OK);
}
if(pRsrv->osSpecific.pfdctx){
status = fdmgr_delete(pRsrv->osSpecific.pfdctx);
assert(status==OK);
}
}
/*
* casOSSpecificInit()
*/
caStatus casOSSpecificInit(struct rsrv *pRsrv)
{
pRsrv->osSpecific.clientQLock = semMCreate(MUTEX_SEM_OPTIONS);
if(!pRsrv->osSpecific.clientQLock){
return S_cas_noMemory;
}
pRsrv->osSpecific.freeChanQLock = semMCreate(MUTEX_SEM_OPTIONS);
if(!pRsrv->osSpecific.freeChanQLock){
casOSSpecificDelete(pRsrv);
return S_cas_noMemory;
}
pRsrv->osSpecific.freeEventQLock = semMCreate(MUTEX_SEM_OPTIONS);
if(!pRsrv->osSpecific.freeEventQLock){
casOSSpecificDelete(pRsrv);
return S_cas_noMemory;
}
pRsrv->osSpecific.pvQLock = semMCreate(MUTEX_SEM_OPTIONS);
if(!pRsrv->osSpecific.pvQLock){
casOSSpecificDelete(pRsrv);
return S_cas_noMemory;
}
pRsrv->osSpecific.pfdctx = fdmgr_init();
if(!pRsrv->osSpecific.pfdctx){
casOSSpecificDelete(pRsrv);
return S_cas_noMemory;
}
return S_cas_success;
}
/*
* casOSSpecificStartServer()
*/
caStatus casOSSpecificStartServer(caserver *pRsrv)
{
int status;
status = fdmgr_add_callback(
pRsrv->osSpecific.pfdctx,
pRsrv->server_sock,
fdi_read,
rsrv_connect,
pRsrv);
if(status < 0){
casOSSpecificDelete(pRsrv);
return S_cas_noMemory;
}
status = taskSpawn(
REQ_SRVR_NAME,
REQ_SRVR_PRI,
REQ_SRVR_OPT,
RSP_SRVR_STACK,
caServerTask,
(int)pRsrv,
0,0,0,0,0,0,0,0,0);
if(status == ERROR){
casOSSpecificDelete(pRsrv);
return S_cas_noMemory;
}
pRsrv->osSpecific.selectTask = status;
return S_cas_success;
}
/*
* caServerTask()
*/
int caServerTask(caserver *pRsrv)
{
struct timeval tv;
caTime delay;
struct client *pClient;
int nchars;
int status;
taskwdInsert((int)taskIdCurrent,NULL,NULL);
while(TRUE){
delay.sec = 100;
delay.usec = 0;
status = caServerProcess (pRsrv, &delay);
assert (status == S_cas_success);
}
}
/*
* casSchedualBeacon()
*/
void casSchedualBeacon(struct rsrv *pRsrv)
{
fdmgrAlarm *tmp;
struct timeval tv;
tv.tv_sec = pRsrv->delayToNextBeacon.tv_sec;
tv.tv_usec = pRsrv->delayToNextBeacon.tv_usec;
tmp = fdmgr_add_timeout(
pRsrv->osSpecific.pfdctx,
&tv,
casSendBeacon,
pRsrv);
if(!tmp){
ca_printf("CAS: Unable to keep beacon going\n");
}
}
/*
* casOSSpecificClientInit()
*/
caStatus casOSSpecificClientInit(struct client *client)
{
client->cc.osSpecific.eventQLock = semMCreate(MUTEX_SEM_OPTIONS);
if(!client->cc.osSpecific.eventQLock){
return S_cas_noMemory;
}
client->cc.osSpecific.chanQLock = semMCreate(MUTEX_SEM_OPTIONS);
if(!client->cc.osSpecific.chanQLock){
casOSSpecificClientDelete(client);
return S_cas_noMemory;
}
client->cc.osSpecific.putNotifyLock = semMCreate(MUTEX_SEM_OPTIONS);
if(!client->cc.osSpecific.putNotifyLock){
casOSSpecificClientDelete(client);
return S_cas_noMemory;
}
client->cc.osSpecific.lock = semMCreate(MUTEX_SEM_OPTIONS);
if(!client->cc.osSpecific.lock){
casOSSpecificClientDelete(client);
return S_cas_noMemory;
}
client->cc.osSpecific.accessRightsQLock = semMCreate(MUTEX_SEM_OPTIONS);
if(!client->cc.osSpecific.accessRightsQLock){
casOSSpecificClientDelete(client);
return S_cas_noMemory;
}
return S_cas_success;
}
/*
* casOSSpecificClientDelete()
*/
void casOSSpecificClientDelete(struct client *client)
{
int status;
if(client->cc.osSpecific.eventQLock){
status = semDelete(client->cc.osSpecific.eventQLock);
assert(status==OK);
}
if(client->cc.osSpecific.chanQLock){
status = semDelete(client->cc.osSpecific.chanQLock);
assert(status==OK);
}
if(client->cc.osSpecific.putNotifyLock){
status = semDelete(client->cc.osSpecific.putNotifyLock);
assert(status==OK);
}
if(client->cc.osSpecific.lock){
status = semDelete(client->cc.osSpecific.lock);
assert(status==OK);
}
if(client->cc.osSpecific.accessRightsQLock){
status = semDelete(client->cc.osSpecific.accessRightsQLock);
assert(status==OK);
}
}
/*
* caeqOSSpecificInit()
*/
caStatus caeqOSSpecificInit(caEventUser *evuser)
{
evuser->osSpecific.lock = semMCreate(MUTEX_SEM_OPTIONS);
if(!evuser->osSpecific.lock){
return S_cas_noMemory;
}
evuser->osSpecific.ppendsem = semBCreate(SEM_Q_PRIORITY, SEM_EMPTY);
if(!evuser->osSpecific.ppendsem){
semDelete(evuser->osSpecific.lock);
return S_cas_noMemory;
}
return S_cas_success;
}
/*
* caeqOSSpecificDelete()
*/
void caeqOSSpecificDelete(caEventUser *evuser)
{
int status;
if(taskIdVerify(evuser->osSpecific.taskid)==OK){
taskwdRemove(evuser->osSpecific.taskid);
taskDelete(evuser->osSpecific.taskid);
}
status = semDelete(evuser->osSpecific.lock);
assert(status == OK);
status = semDelete(evuser->osSpecific.ppendsem);
assert(status == OK);
}
/*
* caeqOSSpecificPVInit ()
*/
caStatus caeqOSSpecificPVInit (casPVInUse *pPV)
{
pPV->osSpecific.lock = semMCreate(MUTEX_SEM_OPTIONS);
if (!pPV->osSpecific.lock) {
return S_cas_noMemory;
}
return S_cas_success;
}
/*
* caeqOSSpecificPVDelete ()
*/
void caeqOSSpecificPVDelete (casPVInUse *pPV)
{
int status;
status = semDelete (pPV->osSpecific.lock);
assert (status == OK);
}
/*
* caeqOSSpecificEventNotify()
*/
void caeqOSSpecificEventNotify(caEventUser *evuser)
{
int status;
status = semGive(evuser->osSpecific.ppendsem);
assert(status == OK);
}
/*
* caeqStartEvents()
*/
int caeqStartEvents(
struct event_user *evuser,
char *taskname, /* defaulted if NULL */
void (*init_func)(),
int init_func_arg,
int priority_offset
)
{
int status;
int taskpri;
/* only one ca_pend_event thread may be started for each evuser ! */
while(!vxTas(&evuser->osSpecific.pendlck))
return ERROR;
status = taskPriorityGet(taskIdSelf(), &taskpri);
if(status == ERROR){
return ERROR;
}
taskpri += priority_offset;
if(!taskname){
taskname = EVENT_PEND_NAME;
}
status = taskSpawn(
taskname,
taskpri,
EVENT_PEND_OPT,
EVENT_PEND_STACK,
event_task,
(int)evuser,
(int)init_func,
(int)init_func_arg,
0,0,0,0,0,0,0);
if(status == ERROR){
return ERROR;
}
evuser->osSpecific.taskid = status;
return OK;
}
/*
* EVENT_TASK()
*/
LOCAL int event_task(
struct event_user *evuser,
void (*init_func)(int init_func_arg),
int init_func_arg
)
{
int status;
taskwdInsert((int)taskIdCurrent,NULL,NULL);
/* init hook */
if(init_func){
(*init_func)(init_func_arg);
}
/*
* No need to lock getix as I only allow one thread to call this
* routine at a time
*/
while(TRUE){
caeqEventProcess(evuser);
status = semTake(evuser->osSpecific.ppendsem, WAIT_FOREVER);
assert(status == OK);
}
}
/*
* caeqOSSpecificClose()
*/
void caeqOSSpecificClose(caEventUser *pEvUser)
{
return;
}
/*
* asciiIPAddr
*/
void asciiIPAddr (struct in_addr addr, char *pBuf, unsigned bufSize)
{
char pName[INET_ADDR_LEN];
inet_ntoa_b (addr, pName);
strncpy (pBuf, pName, bufSize);
pBuf[bufSize-1] = '\0';
}

View File

@@ -1,659 +0,0 @@
/*
*
* vxWorks_depen.c
* %W% %G%
*
* vxWorks dependent routines for the CA server
*
*
*/
#include<casdef.h>
#include <inetLib.h>
VERSIONID(vxWorks_depenc,"%W% %G%")
#define MUTEX_SEM_OPTIONS \
(SEM_Q_PRIORITY | SEM_DELETE_SAFE | SEM_INVERSION_SAFE)
LOCAL int event_task(
struct event_user *evuser,
void (*init_func)(int arg),
int init_func_arg
);
LOCAL void osDepenTimerCB(void *pciu);
LOCAL void osDepenSendCB(void *pClient);
int caServerTask(struct rsrv *pRsrv);
LOCAL int caMaxFreeBlockPoll(void);
size_t caMaxFreeBlock;
###### no event flush currently (only needed in multi thread env) ####
status = caeqAddFlushEvent (client->evuser, XXXX, client);
assert (status==OK);
/*
* caGetElapsedTime()
*/
caStatus caGetElapsedTime(caElapsedTimeVal *pElapsed)
{
ULONG ticks;
ULONG rate;
ticks = tickGet();
rate = sysClkRateGet();
pElapsed->tv_sec = ticks * rate;
pElapsed->tv_usec = ((ticks % rate)*CAServerUSecInSec)/rate;
return S_cas_success;
}
/*
* caOutOfMemory()
*/
int caOutOfMemory(void)
{
int status;
static int pollTaskStarted;
if(!pollTaskStarted){
caMaxFreeBlock = memFindMax();
status = taskSpawn(
MAXFREEBLOCKTASKNAME,
MAXFREEBLOCKTASKPRI,
MAXFREEBLOCKTASKOPT,
MAXFREEBLOCKTASKSTACK,
caMaxFreeBlockPoll,
0,0,0,0,0,0,0,0,0,0);
if(status>=0){
pollTaskStarted = TRUE;
}
}
return (caMaxFreeBlock<MAX_BLOCK_THRESHOLD);
}
/*
* caMaxFreeBlockPoll()
*/
LOCAL int caMaxFreeBlockPoll(void)
{
while(TRUE){
caMaxFreeBlock = memFindMax();
taskDelay(MAXFREEBLOCKPOLL*sysClkRateGet());
}
}
/*
* casPutCBStartTimer()
*/
caStatus casPutCBStartTimer(
casChanInUse *pciu,
unsigned timeOutSec
)
{
struct client *pClient = pciu->client;
caserver *pRsrv = pClient->cc.pRsrv;
struct timeval tv;
if(pClient->cc.osSpecific.pPutCBAlarm){
tv.tv_sec = timeOutSec;
tv.tv_usec = 0;
pClient->cc.osSpecific.pPutCBAlarm
= fdmgr_add_timeout(
pRsrv->osSpecific.pfdctx,
&tv,
osDepenTimerCB,
pciu);
if(!pClient->cc.osSpecific.pPutCBAlarm){
return S_cas_noMemory;
}
}
return S_cas_success;
}
/*
* osDepenTimerCB()
*/
LOCAL void osDepenTimerCB(void *pParam)
{
casChanInUse *pciu = (casChanInUse *)pParam;
pciu->client->cc.osSpecific.pPutCBAlarm = NULL;
casPutCBTimer(pciu);
}
/*
* casPutCBCancelTimer()
*/
void casPutCBCancelTimer(struct client *pClient)
{
caserver *pRsrv = pClient->cc.pRsrv;
int status;
if(pClient->cc.osSpecific.pPutCBAlarm){
status = fdmgr_clear_timeout(
pRsrv->osSpecific.pfdctx,
pClient->cc.osSpecific.pPutCBAlarm);
assert(status==0);
pClient->cc.osSpecific.pPutCBAlarm = NULL;
}
}
/*
* casDisableSocketRecvIOCallback()
*/
caStatus casDisableSocketRecvIOCallback(struct client *pClient)
{
int status;
if(pClient->cc.osSpecific.sockRecvIOCallbackEnabled){
status = fdmgr_clear_callback(
pClient->cc.pRsrv->osSpecific.pfdctx,
pClient->cc.sock,
fdi_read);
assert(status==0);
pClient->cc.osSpecific.sockRecvIOCallbackEnabled = FALSE;
}
return S_cas_success;
}
/*
* casEnableSocketRecvIOCallback()
*/
caStatus casEnableSocketRecvIOCallback(struct client *pClient)
{
caserver *pRsrv = pClient->cc.pRsrv;
int status;
if(!pClient->cc.osSpecific.sockRecvIOCallbackEnabled){
status = fdmgr_add_callback(
pRsrv->osSpecific.pfdctx,
pClient->cc.sock,
fdi_read,
pClient->cc.pCB,
pClient);
if(status){
return S_cas_noMemory;
}
pClient->cc.osSpecific.sockRecvIOCallbackEnabled = TRUE;
}
return S_cas_success;
}
/*
* casWaitForIO ()
*/
caStatus casWaitForIO (struct rsrv *pRsrv, caTime *pDelay)
{
struct timeval tv;
tv.tv_sec = caTime->sec;
tv.tv_usec = caTime->nsec / NSecPerUsec;
status = fdmgr_pend_event(pRsrv->osSpecific.pfdctx, &tv);
if (status) {
return S_cas_internal;
}
return S_cas_success;
}
/*
* casArmSocketSendIOCallback()
*/
caStatus casArmSocketSendIOCallback(struct client *pClient)
{
caserver *pRsrv = pClient->cc.pRsrv;
int status;
if(!pClient->cc.osSpecific.sockSendIOCallbackEnabled){
status = fdmgr_add_callback(
pRsrv->osSpecific.pfdctx,
pClient->cc.sock,
fdi_write,
osDepenSendCB,
pClient);
if(status){
return S_cas_noMemory;
}
pClient->cc.osSpecific.sockSendIOCallbackEnabled = TRUE;
}
return S_cas_success;
}
/*
* casCancelSocketSendIOCallback()
*/
caStatus casCancelSocketSendIOCallback(struct client *pClient)
{
caserver *pRsrv = pClient->cc.pRsrv;
int status;
if(pClient->cc.osSpecific.sockSendIOCallbackEnabled){
status = fdmgr_clear_callback(
pRsrv->osSpecific.pfdctx,
pClient->cc.sock,
fdi_write);
assert(status==0);
pClient->cc.osSpecific.sockSendIOCallbackEnabled = FALSE;
}
return S_cas_success;
}
/*
* osDepenSendCB()
*/
LOCAL void osDepenSendCB(void *pParam)
{
struct client *pClient = (struct client *) pParam;
pClient->cc.osSpecific.sockSendIOCallbackEnabled = FALSE;
(*pClient->sendHandler)(pClient);
}
/*
* casOSSpecificDelete()
*/
void casOSSpecificDelete(struct rsrv *pRsrv)
{
int status;
if(taskIdVerify(pRsrv->osSpecific.selectTask) == OK){
taskwdRemove(taskDelete(pRsrv->osSpecific.selectTask));
taskDelete(pRsrv->osSpecific.selectTask);
}
if(pRsrv->osSpecific.clientQLock){
status = semDelete(pRsrv->osSpecific.clientQLock);
assert(status==OK);
}
if(pRsrv->osSpecific.freeChanQLock){
status = semDelete(pRsrv->osSpecific.freeChanQLock);
assert(status==OK);
}
if(pRsrv->osSpecific.freeEventQLock){
status = semDelete(pRsrv->osSpecific.freeEventQLock);
assert(status==OK);
}
if(pRsrv->osSpecific.pvQLock){
status = semDelete(pRsrv->osSpecific.pvQLock);
assert(status==OK);
}
if(pRsrv->osSpecific.pfdctx){
status = fdmgr_delete(pRsrv->osSpecific.pfdctx);
assert(status==OK);
}
}
/*
* casOSSpecificInit()
*/
caStatus casOSSpecificInit(struct rsrv *pRsrv)
{
pRsrv->osSpecific.clientQLock = semMCreate(MUTEX_SEM_OPTIONS);
if(!pRsrv->osSpecific.clientQLock){
return S_cas_noMemory;
}
pRsrv->osSpecific.freeChanQLock = semMCreate(MUTEX_SEM_OPTIONS);
if(!pRsrv->osSpecific.freeChanQLock){
casOSSpecificDelete(pRsrv);
return S_cas_noMemory;
}
pRsrv->osSpecific.freeEventQLock = semMCreate(MUTEX_SEM_OPTIONS);
if(!pRsrv->osSpecific.freeEventQLock){
casOSSpecificDelete(pRsrv);
return S_cas_noMemory;
}
pRsrv->osSpecific.pvQLock = semMCreate(MUTEX_SEM_OPTIONS);
if(!pRsrv->osSpecific.pvQLock){
casOSSpecificDelete(pRsrv);
return S_cas_noMemory;
}
pRsrv->osSpecific.pfdctx = fdmgr_init();
if(!pRsrv->osSpecific.pfdctx){
casOSSpecificDelete(pRsrv);
return S_cas_noMemory;
}
return S_cas_success;
}
/*
* casOSSpecificStartServer()
*/
caStatus casOSSpecificStartServer(caserver *pRsrv)
{
int status;
status = fdmgr_add_callback(
pRsrv->osSpecific.pfdctx,
pRsrv->server_sock,
fdi_read,
rsrv_connect,
pRsrv);
if(status < 0){
casOSSpecificDelete(pRsrv);
return S_cas_noMemory;
}
status = taskSpawn(
REQ_SRVR_NAME,
REQ_SRVR_PRI,
REQ_SRVR_OPT,
RSP_SRVR_STACK,
caServerTask,
(int)pRsrv,
0,0,0,0,0,0,0,0,0);
if(status == ERROR){
casOSSpecificDelete(pRsrv);
return S_cas_noMemory;
}
pRsrv->osSpecific.selectTask = status;
return S_cas_success;
}
/*
* caServerTask()
*/
int caServerTask(caserver *pRsrv)
{
struct timeval tv;
caTime delay;
struct client *pClient;
int nchars;
int status;
taskwdInsert((int)taskIdCurrent,NULL,NULL);
while(TRUE){
delay.sec = 100;
delay.usec = 0;
status = caServerProcess (pRsrv, &delay);
assert (status == S_cas_success);
}
}
/*
* casSchedualBeacon()
*/
void casSchedualBeacon(struct rsrv *pRsrv)
{
fdmgrAlarm *tmp;
struct timeval tv;
tv.tv_sec = pRsrv->delayToNextBeacon.tv_sec;
tv.tv_usec = pRsrv->delayToNextBeacon.tv_usec;
tmp = fdmgr_add_timeout(
pRsrv->osSpecific.pfdctx,
&tv,
casSendBeacon,
pRsrv);
if(!tmp){
ca_printf("CAS: Unable to keep beacon going\n");
}
}
/*
* casOSSpecificClientInit()
*/
caStatus casOSSpecificClientInit(struct client *client)
{
client->cc.osSpecific.eventQLock = semMCreate(MUTEX_SEM_OPTIONS);
if(!client->cc.osSpecific.eventQLock){
return S_cas_noMemory;
}
client->cc.osSpecific.chanQLock = semMCreate(MUTEX_SEM_OPTIONS);
if(!client->cc.osSpecific.chanQLock){
casOSSpecificClientDelete(client);
return S_cas_noMemory;
}
client->cc.osSpecific.putNotifyLock = semMCreate(MUTEX_SEM_OPTIONS);
if(!client->cc.osSpecific.putNotifyLock){
casOSSpecificClientDelete(client);
return S_cas_noMemory;
}
client->cc.osSpecific.lock = semMCreate(MUTEX_SEM_OPTIONS);
if(!client->cc.osSpecific.lock){
casOSSpecificClientDelete(client);
return S_cas_noMemory;
}
client->cc.osSpecific.accessRightsQLock = semMCreate(MUTEX_SEM_OPTIONS);
if(!client->cc.osSpecific.accessRightsQLock){
casOSSpecificClientDelete(client);
return S_cas_noMemory;
}
return S_cas_success;
}
/*
* casOSSpecificClientDelete()
*/
void casOSSpecificClientDelete(struct client *client)
{
int status;
if(client->cc.osSpecific.eventQLock){
status = semDelete(client->cc.osSpecific.eventQLock);
assert(status==OK);
}
if(client->cc.osSpecific.chanQLock){
status = semDelete(client->cc.osSpecific.chanQLock);
assert(status==OK);
}
if(client->cc.osSpecific.putNotifyLock){
status = semDelete(client->cc.osSpecific.putNotifyLock);
assert(status==OK);
}
if(client->cc.osSpecific.lock){
status = semDelete(client->cc.osSpecific.lock);
assert(status==OK);
}
if(client->cc.osSpecific.accessRightsQLock){
status = semDelete(client->cc.osSpecific.accessRightsQLock);
assert(status==OK);
}
}
/*
* caeqOSSpecificInit()
*/
caStatus caeqOSSpecificInit(caEventUser *evuser)
{
evuser->osSpecific.lock = semMCreate(MUTEX_SEM_OPTIONS);
if(!evuser->osSpecific.lock){
return S_cas_noMemory;
}
evuser->osSpecific.ppendsem = semBCreate(SEM_Q_PRIORITY, SEM_EMPTY);
if(!evuser->osSpecific.ppendsem){
semDelete(evuser->osSpecific.lock);
return S_cas_noMemory;
}
return S_cas_success;
}
/*
* caeqOSSpecificDelete()
*/
void caeqOSSpecificDelete(caEventUser *evuser)
{
int status;
if(taskIdVerify(evuser->osSpecific.taskid)==OK){
taskwdRemove(evuser->osSpecific.taskid);
taskDelete(evuser->osSpecific.taskid);
}
status = semDelete(evuser->osSpecific.lock);
assert(status == OK);
status = semDelete(evuser->osSpecific.ppendsem);
assert(status == OK);
}
/*
* caeqOSSpecificPVInit ()
*/
caStatus caeqOSSpecificPVInit (casPVInUse *pPV)
{
pPV->osSpecific.lock = semMCreate(MUTEX_SEM_OPTIONS);
if (!pPV->osSpecific.lock) {
return S_cas_noMemory;
}
return S_cas_success;
}
/*
* caeqOSSpecificPVDelete ()
*/
void caeqOSSpecificPVDelete (casPVInUse *pPV)
{
int status;
status = semDelete (pPV->osSpecific.lock);
assert (status == OK);
}
/*
* caeqOSSpecificEventNotify()
*/
void caeqOSSpecificEventNotify(caEventUser *evuser)
{
int status;
status = semGive(evuser->osSpecific.ppendsem);
assert(status == OK);
}
/*
* caeqStartEvents()
*/
int caeqStartEvents(
struct event_user *evuser,
char *taskname, /* defaulted if NULL */
void (*init_func)(),
int init_func_arg,
int priority_offset
)
{
int status;
int taskpri;
/* only one ca_pend_event thread may be started for each evuser ! */
while(!vxTas(&evuser->osSpecific.pendlck))
return ERROR;
status = taskPriorityGet(taskIdSelf(), &taskpri);
if(status == ERROR){
return ERROR;
}
taskpri += priority_offset;
if(!taskname){
taskname = EVENT_PEND_NAME;
}
status = taskSpawn(
taskname,
taskpri,
EVENT_PEND_OPT,
EVENT_PEND_STACK,
event_task,
(int)evuser,
(int)init_func,
(int)init_func_arg,
0,0,0,0,0,0,0);
if(status == ERROR){
return ERROR;
}
evuser->osSpecific.taskid = status;
return OK;
}
/*
* EVENT_TASK()
*/
LOCAL int event_task(
struct event_user *evuser,
void (*init_func)(int init_func_arg),
int init_func_arg
)
{
int status;
taskwdInsert((int)taskIdCurrent,NULL,NULL);
/* init hook */
if(init_func){
(*init_func)(init_func_arg);
}
/*
* No need to lock getix as I only allow one thread to call this
* routine at a time
*/
while(TRUE){
caeqEventProcess(evuser);
status = semTake(evuser->osSpecific.ppendsem, WAIT_FOREVER);
assert(status == OK);
}
}
/*
* caeqOSSpecificClose()
*/
void caeqOSSpecificClose(caEventUser *pEvUser)
{
return;
}
/*
* asciiIPAddr
*/
void asciiIPAddr (struct in_addr addr, char *pBuf, unsigned bufSize)
{
char pName[INET_ADDR_LEN];
inet_ntoa_b (addr, pName);
strncpy (pBuf, pName, bufSize);
pBuf[bufSize-1] = '\0';
}

View File

@@ -1,256 +0,0 @@
#include <vxWorks.h>
#include <taskLib.h>
#include <errnoLib.h>
#include <logLib.h>
#include <tickLib.h>
#include <sysLib.h>
#include <vxLib.h>
#include <ioLib.h>
#include <usrLib.h>
#include <semLib.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sockLib.h> /* for sendto() setsockopt() etc */
#include <netinet/in.h>
#include <netinet/tcp.h>
/*
* EPICS on vxWorks
*/
#include <task_params.h>
#include <taskwd.h>
#include <fdmgr.h>
extern size_t caMaxFreeBlock;
#define MAXFREEBLOCKPOLL 5 /* sec */
#define MAXFREEBLOCKTASKNAME "caMemPoll"
#define MAXFREEBLOCKTASKPRI 255
#define MAXFREEBLOCKTASKOPT (VX_FP_TASK)
#define MAXFREEBLOCKTASKSTACK 4095
/*
* per server locks
* ================
*/
#define LOCK_CLIENTQ(PRSRV) \
{ \
int status; \
status = semTake((PRSRV)->osSpecific.clientQLock, WAIT_FOREVER); \
assert(status==OK); \
}
#define UNLOCK_CLIENTQ(PRSRV) \
{ \
int status; \
status = semGive((PRSRV)->osSpecific.clientQLock); \
assert(status==OK); \
}
#define LOCK_FREE_CHAN_Q(PRSRV) \
{\
int status;\
status = semTake((PRSRV)->osSpecific.freeChanQLock, WAIT_FOREVER);\
assert(status==OK);\
}
#define UNLOCK_FREE_CHAN_Q(PRSRV) \
{ \
int status;\
status = semGive((PRSRV)->osSpecific.freeChanQLock);\
assert(status==OK);\
}
#define LOCK_FREE_EVENT_Q(PRSRV) \
{\
int status;\
status = semTake((PRSRV)->osSpecific.freeEventQLock, WAIT_FOREVER);\
assert(status==OK);\
}
#define UNLOCK_FREE_EVENT_Q(PRSRV) \
{ \
int status;\
status = semGive((PRSRV)->osSpecific.freeEventQLock);\
assert(status==OK);\
}
#define LOCK_PVQ(PRSRV) \
{ \
int status; \
status = semTake((PRSRV)->osSpecific.pvQLock, WAIT_FOREVER); \
assert(status==OK); \
}
#define UNLOCK_PVQ(PRSRV) \
{ \
int status;\
status = semGive((PRSRV)->osSpecific.pvQLock);\
assert(status==OK);\
}
/*
* per client locks
* ================
*/
#define SEND_LOCK(CLIENT) \
{\
int status;\
status = semTake((CLIENT)->cc.osSpecific.lock, WAIT_FOREVER);\
assert(status==OK);\
}
#define SEND_UNLOCK(CLIENT) \
{ \
int status;\
status = semGive((CLIENT)->cc.osSpecific.lock);\
assert(status==OK);\
}
#define LOCK_CHAN_Q(PCLIENT) \
{\
int status;\
status = semTake((PCLIENT)->cc.osSpecific.chanQLock, WAIT_FOREVER);\
assert(status==OK);\
}
#define UNLOCK_CHAN_Q(PCLIENT) \
{ \
int status;\
status = semGive((PCLIENT)->cc.osSpecific.chanQLock);\
assert(status==OK);\
}
#define LOCK_EVENT_Q(PCLIENT) \
{\
int status;\
status = semTake((PCLIENT)->cc.osSpecific.eventQLock, WAIT_FOREVER);\
assert(status==OK);\
}
#define UNLOCK_EVENT_Q(PCLIENT) \
{ \
int status;\
status = semGive((PCLIENT)->cc.osSpecific.eventQLock);\
assert(status==OK);\
}
#define LOCK_PUT_NOTIFY(PCLIENT) \
{\
int status;\
status = semTake((PCLIENT)->cc.osSpecific.putNotifyLock, WAIT_FOREVER);\
assert(status==OK);\
}
#define UNLOCK_PUT_NOTIFY(PCLIENT) \
{ \
int status;\
status = semGive((PCLIENT)->cc.osSpecific.putNotifyLock);\
assert(status==OK);\
}
#define LOCK_ACCESS_RIGHTS_Q(PCLIENT) \
{\
int status;\
status = semTake((PCLIENT)->cc.osSpecific.accessRightsQLock, \
WAIT_FOREVER);\
assert(status==OK);\
}
#define UNLOCK_ACCESS_RIGHTS_Q(PCLIENT) \
{ \
int status;\
status = semGive((PCLIENT)->cc.osSpecific.accessRightsQLock);\
assert(status==OK);\
}
/*
* event system locks
* ==================
*/
#define CA_EVENT_LOCK(PEVUSER) \
{ \
int status;\
status = semTake((PEVUSER)->osSpecific.lock, WAIT_FOREVER);\
assert(status==OK);\
}
#define CA_EVENT_UNLOCK(PEVUSER) \
{ \
int status;\
status = semGive((PEVUSER)->osSpecific.lock);\
assert(status==OK);\
}
#define LOCK_PV(PPV) \
{ \
int status;\
status = semTake((PPV)->osSpecific.lock, WAIT_FOREVER);\
assert(status==OK);\
}
#define UNLOCK_PV(PPV) \
{ \
int status;\
status = semGive((PPV)->osSpecific.lock);\
assert(status==OK);\
}
/*
* vxWorks specific addition to event_user struct
*/
typedef struct {
SEM_ID lock;
SEM_ID ppendsem;
int taskid;
char pendlck;
}caeqOsSpecific;
typedef struct {
SEM_ID lock;
}caPVOsSpecific;
/*
* vxWorks specific addition to rsrv struct
*/
typedef struct {
fdctx *pfdctx;
SEM_ID clientQLock;
SEM_ID pvQLock;
SEM_ID freeChanQLock;
SEM_ID freeEventQLock;
int selectTask;
}rsrvOsSpecific;
/*
* vxWorks specific addition to client struct
*/
typedef struct {
SEM_ID lock;
SEM_ID putNotifyLock;
SEM_ID chanQLock;
SEM_ID eventQLock;
SEM_ID accessRightsQLock;
fdmgrAlarm *pPutCBAlarm;
unsigned sockSendIOCallbackEnabled:1;
unsigned sockRecvIOCallbackEnabled:1;
}clientOsSpecific;
typedef int SOCKET;
#define SOCKERRNO errno
#define socket_close(S) close(S)
/* vxWorks still has brain dead func proto for ioctl() */
#define socket_ioctl(A,B,C) ioctl(A,B,(int)C)
/* leave task around for debugging if we fail */
#define abort(A) taskSuspend(0)

View File

@@ -259,6 +259,7 @@ gen_rectype:
if(pfldDes->field_type==DBF_NOACCESS) {
char *prtn;
char fldname[5];
char *ptemp;
strcpy(fldname,pfldDes->fldname);
pstr = fldname;
@@ -277,8 +278,21 @@ gen_rectype:
pfldDes->fldname,recordtypeInclude);
break;
}
if(!(pstr = strstr(includeLine,fldname))) continue;
if(isalnum(*(pstr + strlen(fldname)))) continue;
ptemp = &includeLine[0];
while(TRUE) {
if(!ptemp) break;
if(!(pstr = strstr(ptemp,fldname))) {
ptemp = NULL;
break;
}
if(isalnum(*(pstr-1))
|| isalnum(*(pstr + strlen(fldname)))) {
ptemp = pstr + 1;
continue;
}
break;
}
if(!ptemp) continue;
break;
}
if(!prtn) continue;

View File

@@ -29,6 +29,9 @@
*
* History
* $Log$
* Revision 1.4 1996/08/05 19:31:59 jhill
* fixed removes use of iter.cur()
*
* Revision 1.3 1996/07/25 17:58:16 jhill
* fixed missing ref in list decl
*
@@ -58,6 +61,9 @@ typedef unsigned resTableIndex;
const unsigned resTableIndexBitWidth = (sizeof(resTableIndex)*CHAR_BIT);
//
// class T must derive class ID
//
template <class T, class ID>
class resTable {
public:
@@ -106,7 +112,6 @@ public:
while (pList<&this->pTable[this->hashIdMask+1]) {
tsSLIter<T> iter(*pList);
T *pItem;
while ( (pItem = iter()) ) {
iter.remove();
delete pItem;
@@ -248,7 +253,7 @@ private:
//
class uintId {
public:
uintId(unsigned idIn=~0u) : id(idIn) {}
uintId(unsigned idIn=UINT_MAX) : id(idIn) {}
resTableIndex resourceHash(unsigned nBitsId) const
{
@@ -267,7 +272,7 @@ public:
//
return hashid;
}
int operator == (const uintId &idIn)
{
return this->id == idIn.id;
@@ -287,11 +292,15 @@ protected:
template <class ITEM>
class uintRes : public uintId, public tsSLNode<ITEM> {
friend class uintResTable<ITEM>;
public:
uintRes(unsigned idIn=UINT_MAX) : uintId(idIn) {}
};
//
// special resource table which uses
// unsigned integer keys allocated in chronological sequence
//
// NOTE: ITEM must public inherit from uintRes<ITEM>
//
template <class ITEM>
class uintResTable : public resTable<ITEM, uintId> {
@@ -360,17 +369,33 @@ private:
//
class stringId {
public:
stringId (char const * const idIn) : id(idIn) {}
stringId (char const * const idIn) :
pStr(new char [strlen(idIn)+1u])
{
if (this->pStr!=NULL) {
strcpy(this->pStr, idIn);
}
}
~ stringId()
{
if (this->pStr!=NULL) {
delete [] this->pStr;
}
}
resTableIndex resourceHash(unsigned nBitsId) const
{
const char *pStr = this->id;
resTableIndex hashid;
unsigned i;
if (this->pStr==NULL) {
return 0u;
}
hashid = 0u;
for (i=0u; pStr[i]; i++) {
hashid += pStr[i] * (i+1u);
for (i=0u; this->pStr[i]; i++) {
hashid += this->pStr[i] * (i+1u);
}
hashid = hashid % (1u<<nBitsId);
@@ -380,20 +405,25 @@ public:
int operator == (const stringId &idIn)
{
return strcmp(this->id,idIn.id)==0;
if (this->pStr!=NULL && idIn.pStr!=NULL) {
return strcmp(this->pStr,idIn.pStr)==0;
}
else {
return 0u; // not equal
}
}
const char * resourceName()
{
return id;
return this->pStr;
}
void show (unsigned)
{
printf ("resource id = %s\n", id);
printf ("resource id = %s\n", this->pStr);
}
private:
char const * const id;
char * const pStr;
};
#endif // INCresourceLibh

View File

@@ -23,68 +23,127 @@ private:
const char * const pName;
};
class jane : public stringId, tsSLNode<jane> {
public:
jane (const char *pNameIn) : stringId(pNameIn) {}
};
main()
{
unsigned i;
clock_t start, finish;
double duration;
const int LOOPS = 500000;
resTable<fred,uintId> tbl;
const int LOOPS = 50000;
resTable<fred,uintId> intTbl;
resTable<jane,stringId> strTbl;
fred fred1("fred1",0x1000a432);
fred fred2("fred2",0x0000a432);
jane jane1("jane1");
jane jane2("jane2");
fred *pFred;
uintId id1(0x1000a432);
uintId id2(0x0000a432);
jane *pJane;
uintId uintId1(0x1000a432);
uintId uintId2(0x0000a432);
stringId strId1("jane1");
stringId strId2("jane2");
int status;
status = tbl.init(8);
status = intTbl.init(8);
if (status) {
return -1;
}
status = tbl.add(fred1);
status = intTbl.add(fred1);
assert (!status);
status = tbl.add(fred2);
status = intTbl.add(fred2);
assert (!status);
start = clock();
for(i=0; i<LOOPS; i++){
pFred = tbl.lookup(id1);
pFred = intTbl.lookup(uintId1);
assert(pFred==&fred1);
pFred = tbl.lookup(id1);
pFred = intTbl.lookup(uintId1);
assert(pFred==&fred1);
pFred = tbl.lookup(id1);
pFred = intTbl.lookup(uintId1);
assert(pFred==&fred1);
pFred = tbl.lookup(id1);
pFred = intTbl.lookup(uintId1);
assert(pFred==&fred1);
pFred = tbl.lookup(id1);
pFred = intTbl.lookup(uintId1);
assert(pFred==&fred1);
pFred = tbl.lookup(id1);
pFred = intTbl.lookup(uintId1);
assert(pFred==&fred1);
pFred = tbl.lookup(id1);
pFred = intTbl.lookup(uintId1);
assert(pFred==&fred1);
pFred = tbl.lookup(id1);
pFred = intTbl.lookup(uintId1);
assert(pFred==&fred1);
pFred = tbl.lookup(id1);
pFred = intTbl.lookup(uintId1);
assert(pFred==&fred1);
pFred = tbl.lookup(id2);
pFred = intTbl.lookup(uintId2);
assert(pFred==&fred2);
}
finish = clock();
duration = finish-start;
duration /= CLOCKS_PER_SEC;
printf("It took %15.10f total sec\n", duration);
printf("It took %15.10f total sec for integer hash lookups\n", duration);
duration /= LOOPS;
duration /= 10;
duration *= 1e6;
printf("It took %15.10f u sec per hash lookup\n", duration);
printf("It took %15.10f u sec per integer hash lookup\n", duration);
tbl.show(10u);
intTbl.show(10u);
tbl.remove(id1);
tbl.remove(id2);
intTbl.remove(uintId1);
intTbl.remove(uintId2);
status = strTbl.init(8);
if (status) {
return -1;
}
status = strTbl.add(jane1);
assert (!status);
status = strTbl.add(jane2);
assert (!status);
start = clock();
for(i=0; i<LOOPS; i++){
pJane = strTbl.lookup(strId1);
assert(pJane==&jane1);
pJane = strTbl.lookup(strId1);
assert(pJane==&jane1);
pJane = strTbl.lookup(strId1);
assert(pJane==&jane1);
pJane = strTbl.lookup(strId1);
assert(pJane==&jane1);
pJane = strTbl.lookup(strId1);
assert(pJane==&jane1);
pJane = strTbl.lookup(strId1);
assert(pJane==&jane1);
pJane = strTbl.lookup(strId1);
assert(pJane==&jane1);
pJane = strTbl.lookup(strId1);
assert(pJane==&jane1);
pJane = strTbl.lookup(strId1);
assert(pJane==&jane1);
pJane = strTbl.lookup(strId2);
assert(pJane==&jane2);
}
finish = clock();
duration = finish-start;
duration /= CLOCKS_PER_SEC;
printf("It took %15.10f total sec for string hash lookups\n", duration);
duration /= LOOPS;
duration /= 10;
duration *= 1e6;
printf("It took %15.10f u sec per string hash lookup\n", duration);
strTbl.show(10u);
strTbl.remove(strId1);
strTbl.remove(strId2);
return 0;
}

View File

@@ -31,6 +31,9 @@
*
* History
* $Log$
* Revision 1.3 1996/07/25 18:01:42 jhill
* use pointer (not ref) for list in iter class
*
* Revision 1.2 1996/07/24 22:12:04 jhill
* added remove() to iter class + made node's prev/next private
*
@@ -125,7 +128,7 @@ template <class T>
class tsSLIter {
public:
tsSLIter(tsSLList<T> &listIn) :
pList(&listIn), pCurrent(0), pPrevious(0) {}
pCurrent(0), pPrevious(0), pList(&listIn) {}
void reset()
{

View File

@@ -57,6 +57,7 @@ device(ai,CONSTANT,devAiSoft,"Soft Channel")
#device(ai,AB_IO,devAiAb1771Ife0to5V,"AB-1771IFE-0to5Volt")
#device(ai,AB_IO,devAiAb1771IrPlatinum,"AB-1771RTD-Platinum")
#device(ai,AB_IO,devAiAb1771IrCopper,"AB-1771RTD-Copper")
#device(ai,AB_IO,devAiAbSclDcm,"AB-SCL500DCM")
#device(ai,CAMAC_IO,devAiCamac,"Camac")
#device(ai,VME_IO,devAiAt5Vxi,"VXI-AT5-AI")
#device(ai,GPIB_IO,devAiK486Gpib,"Keithley-486")
@@ -69,6 +70,7 @@ device(ao,CONSTANT,devAoSoft,"Soft Channel")
#device(ao,CONSTANT,devAoTestAsyn,"Test Asyn")
#device(ao,CONSTANT,devAoSymb,"vxWorks Variable")
#device(ao,AB_IO,devAoAb1771Ofe,"AB-1771OFE")
#device(ao,AB_IO,devAoAbSclDcm,"AB-SCL500DCM")
#device(ao,CAMAC_IO,devAoCamac,"Camac")
#device(ao,VME_IO,devAoAt5Vxi,"VXI-AT5-AO")
device(bi,CONSTANT,devBiSoft,"Soft Channel")
@@ -113,9 +115,11 @@ device(event,CONSTANT,devEventSoft,"Soft Channel")
device(longin,CONSTANT,devLiSoft,"Soft Channel")
device(longin,CONSTANT,devLiSymb,"vxWorks Variable")
#device(longin,CAMAC_IO,devLiCamac,"Camac")
#device(longin,AB_IO,devLiAbSclDcm,"AB-SCL500DCM")
device(longout,CONSTANT,devLoSoft,"Soft Channel")
device(longout,CONSTANT,devLoSymb,"vxWorks Variable")
#device(longout,CAMAC_IO,devLoCamac,"Camac")
#device(longout,AB_IO,devLoAbSclDcm,"AB-SCL500DCM")
device(mbbi,CONSTANT,devMbbiSoft,"Soft Channel")
#device(mbbi,CONSTANT,devMbbiSoftRaw,"Raw Soft Channel")
#device(mbbi,VME_IO,devMbbiMpv910,"MPV-910")

View File

@@ -143,6 +143,7 @@ LIBOBJS += $(EPICS_BASE_BIN)/devWfTestAsyn.o
#LIBOBJS += $(EPICS_BASE_BIN)/devAB1771IR.o
#LIBOBJS += $(EPICS_BASE_BIN)/devAB1771IXE.o
#LIBOBJS += $(EPICS_BASE_BIN)/devAB1771OFE.o
#LIBOBJS += $(EPICS_BASE_BIN)/devABSLCDCM.o
#LIBOBJS += $(EPICS_BASE_BIN)/devABBINARY.o
#LIBOBJS += $(EPICS_BASE_BIN)/devABStatus.o
#LIBOBJS += $(EPICS_BASE_BIN)/devMpc.o

View File

@@ -670,7 +670,7 @@ long dbGetLinkValue(struct link *plink, short dbrType, void *pbuffer,
precord->pact = pact;
if(status) return(status);
}
if(ppv_link->pvlMask&pvlOptMS)
if(ppv_link->pvlMask&pvlOptMS && precord!= paddr->precord)
recGblSetSevr(precord,LINK_ALARM,paddr->precord->sevr);
if(ppv_link->getCvt && ppv_link->lastGetdbrType==dbrType) {
@@ -780,6 +780,7 @@ long dbGetField( DBADDR *paddr,short dbrType,void *pbuffer,
}
if(options && (*options))
getOptions(paddr,(void **)&pbuf,options,pflin);
if(nRequest && *nRequest==0) goto done;
dbInitEntry(pdbbase,&dbEntry);
if(status = dbFindRecord(&dbEntry,precord->name)) goto done;
if(status = dbFindField(&dbEntry,pfldDes->name)) goto done;
@@ -951,6 +952,10 @@ long dbPutField(DBADDR *paddr,short dbrType,void *pbuffer,long nRequest)
if(status) return(status);
}
if(status=dbPutString(&dbEntry,buffer)) goto done;
if(special) {
status = putSpecial(paddr,1);
if(status) return(status);
}
if(plink->type == PV_LINK) {
DBADDR dbaddr;
@@ -982,10 +987,6 @@ long dbPutField(DBADDR *paddr,short dbrType,void *pbuffer,long nRequest)
}
}
}
if(special) {
status = putSpecial(paddr,1);
if(status) return(status);
}
db_post_events(precord,plink,DBE_VALUE);
dbFinishEntry(&dbEntry);
done:

View File

@@ -298,6 +298,17 @@ void dbCaRemoveLink(struct link *plink);
long dbCaGetLink(struct link *plink,short dbrType,void *pbuffer,
unsigned short *psevr,long *nRequest);
long dbCaPutLink(struct link *plink,short dbrType,void *pbuffer,long nRequest);
long dbCaGetAttributes(struct link *plink,
void (*callback)(void *usrPvt),void *usrPvt);
long dbCaGetControlLimits(struct link *plink,double *low, double *high);
long dbCaGetGraphicLimits(struct link *plink,double *low, double *high);
long dbCaGetAlarmLimits(struct link *plink,
double *lolo, double *low, double *high, double *hihi);
long dbCaGetNelements(struct link *plink,long *nelements);
long dbCaGetPrecision(struct link *plink,short *precision);
long dbCaGetSevr(struct link *plink,short *severity);
long dbCaGetUnits(struct link *plink,char *units,int unitsSize);
int dbCaIsLinkConnected(struct link *plink);
#else
struct rset *dbGetRset();

View File

@@ -260,6 +260,152 @@ long dbCaPutLink(struct link *plink,short dbrType,
return(status);
}
long dbCaGetAttributes(struct link *plink,
void (*callback)(void *usrPvt),void *usrPvt)
{
caLink *pca;
long status = 0;
STATUS semStatus;
short link_action = 0;
caAttributes *pcaAttributes;
if(!plink || (plink->type!=CA_LINK)) {
epicsPrintf("dbCaGetAttributes: called for non CA_LINK\n");
return(-1);
}
pca = (caLink *)plink->value.pv_link.pvt;
if(!pca) {
epicsPrintf("dbCaGetAttributes: record %s pv_link.pvt is NULL\n",
plink->value.pv_link.precord);
return(-1);
}
if(pca->pcaAttributes) {
epicsPrintf("dbCaGetAttributes: record %s duplicate call\n",
plink->value.pv_link.precord);
return(-1);
}
pcaAttributes = dbCalloc(1,sizeof(caAttributes));
pcaAttributes->callback = callback;
pcaAttributes->usrPvt = usrPvt;
semStatus = semTake(pca->lock,WAIT_FOREVER);
if(semStatus!=OK) {
epicsPrintf("dbCaGetLink: semStatus!OK\n");
return(-1);
}
pca->pcaAttributes = pcaAttributes;
link_action |= CA_GET_ATTRIBUTES;
semGive(pca->lock);
addAction(pca,link_action);
return(status);
}
caAttributes *getpcaAttributes(struct link *plink)
{
caLink *pca;
if(!plink || (plink->type!=CA_LINK)) return(NULL);
pca = (caLink *)plink->value.pv_link.pvt;
if(!pca) return(NULL);
if(ca_state(pca->chid)!=cs_conn) return(NULL);
return(pca->pcaAttributes);
}
long dbCaGetControlLimits(struct link *plink,double *low, double *high)
{
caAttributes *pcaAttributes;
pcaAttributes = getpcaAttributes(plink);
if(!pcaAttributes) return(-1);
*low = pcaAttributes->data.lower_ctrl_limit;
*high = pcaAttributes->data.upper_ctrl_limit;
return(0);
}
long dbCaGetGraphicLimits(struct link *plink,double *low, double *high)
{
caAttributes *pcaAttributes;
pcaAttributes = getpcaAttributes(plink);
if(!pcaAttributes) return(-1);
*low = pcaAttributes->data.lower_disp_limit;
*high = pcaAttributes->data.upper_disp_limit;
return(0);
}
long dbCaGetAlarmLimits(struct link *plink,
double *lolo, double *low, double *high, double *hihi)
{
caAttributes *pcaAttributes;
pcaAttributes = getpcaAttributes(plink);
if(!pcaAttributes) return(-1);
*lolo = pcaAttributes->data.lower_alarm_limit;
*low = pcaAttributes->data.lower_warning_limit;
*high = pcaAttributes->data.upper_warning_limit;
*hihi = pcaAttributes->data.upper_alarm_limit;
return(0);
}
long dbCaGetPrecision(struct link *plink,short *precision)
{
caAttributes *pcaAttributes;
pcaAttributes = getpcaAttributes(plink);
if(!pcaAttributes) return(-1);
*precision = pcaAttributes->data.precision;
return(0);
}
long dbCaGetUnits(struct link *plink,char *units,int unitsSize)
{
caAttributes *pcaAttributes;
pcaAttributes = getpcaAttributes(plink);
if(!pcaAttributes) return(-1);
strncpy(units,pcaAttributes->data.units,unitsSize);
units[unitsSize-1] = 0;
return(0);
}
long dbCaGetNelements(struct link *plink,long *nelements)
{
caLink *pca;
if(!plink) return(-1);
if(plink->type != CA_LINK) return(-1);
pca = (caLink *)plink->value.pv_link.pvt;
if(!pca) return(-1);
if(ca_state(pca->chid)!=cs_conn) return(-1);
*nelements = pca->nelements;
return(0);
}
long dbCaGetSevr(struct link *plink,short *severity)
{
caLink *pca;
if(!plink) return(-1);
if(plink->type != CA_LINK) return(-1);
pca = (caLink *)plink->value.pv_link.pvt;
if(!pca) return(-1);
if(ca_state(pca->chid)!=cs_conn) return(-1);
*severity = pca->sevr;
return(0);
}
int dbCaIsLinkConnected(struct link *plink)
{
caLink *pca;
if(!plink) return(FALSE);
if(plink->type != CA_LINK) return(FALSE);
pca = (caLink *)plink->value.pv_link.pvt;
if(!pca) return(FALSE);
if(!pca->chid) return(FALSE);
if(ca_state(pca->chid)==cs_conn) return(TRUE);
return(FALSE);
}
static void eventCallback(struct event_handler_args arg)
{
caLink *pca = (caLink *)arg.usr;
@@ -326,6 +472,39 @@ done:
semGive(pca->lock);
}
static void getAttribEventCallback(struct event_handler_args arg)
{
caLink *pca = (caLink *)arg.usr;
struct link *plink;
STATUS semStatus;
struct dbr_ctrl_double *dbr;
caAttributes *pcaAttributes = NULL;
if(!pca) {
epicsPrintf("getAttribEventCallback why was arg.usr NULL\n");
return;
}
semStatus = semTake(pca->lock,WAIT_FOREVER);
if(semStatus!=OK) {
epicsPrintf("getAttribEventCallback: semStatus!OK\n");
return;
}
plink = pca->plink;
if(!plink) goto done;
if(!arg.dbr) {
epicsPrintf("getAttribEventCallback why was arg.dbr NULL\n");
goto done;
}
dbr = arg.dbr;
pcaAttributes = pca->pcaAttributes;
if(!pcaAttributes) goto done;
pcaAttributes->data = *dbr; /*copy entire structure*/
pcaAttributes->gotData = TRUE;
(pcaAttributes->callback)(pcaAttributes->usrPvt);
done:
semGive(pca->lock);
}
static void accessRightsCallback(struct access_rights_handler_args arg)
{
caLink *pca = (caLink *)ca_puser(arg.chid);
@@ -414,6 +593,7 @@ static void connectionCallback(struct connection_handler_args arg)
if((plink->value.pv_link.pvlMask & pvlOptOutString) && (pca->gotOutString)){
link_action |= CA_WRITE_STRING;
}
if(pca->pcaAttributes) link_action |= CA_GET_ATTRIBUTES;
done:
semGive(pca->lock);
if(link_action) addAction(pca,link_action);
@@ -442,6 +622,7 @@ void dbCaTask()
free(pca->pputNative);
free(pca->pgetString);
free(pca->pputString);
free(pca->pcaAttributes);
semDelete(pca->lock);
free(pca);
continue; /*No other link_action makes sense*/
@@ -499,6 +680,13 @@ void dbCaTask()
epicsPrintf("dbCaTask ca_add_array_event %s\n",
ca_message(status));
}
if(link_action&CA_GET_ATTRIBUTES) {
status = ca_get_callback(DBR_CTRL_DOUBLE,
pca->chid,getAttribEventCallback,pca);
if(status!=ECA_NORMAL)
epicsPrintf("dbCaTask ca_add_array_event %s\n",
ca_message(status));
}
} else { /* caList was empty */
semGive(caListSem);
break; /*caList is empty*/

View File

@@ -30,6 +30,16 @@ of this distribution.
#define CA_WRITE_STRING 0x8
#define CA_MONITOR_NATIVE 0x10
#define CA_MONITOR_STRING 0x20
#define CA_GET_ATTRIBUTES 0x40
typedef struct caAttributes
{
void (*callback)(void *usrPvt);
struct dbr_ctrl_double data;
void *usrPvt;
int gotData;
}caAttributes;
typedef struct caLink
{
ELLNODE node;
@@ -39,6 +49,7 @@ typedef struct caLink
void *pputNative;
char *pgetString;
char *pputString;
caAttributes *pcaAttributes;
long nelements;
SEM_ID lock;
unsigned long nDisconnect;

View File

@@ -319,6 +319,7 @@ void dbLockSetMerge(dbCommon *pfirst,dbCommon *psecond)
lockSet *p1lockSet;
lockSet *p2lockSet;
if(pfirst==psecond) return;
p1lockSet = p1lockRecord->plockSet;
p2lockSet = p2lockRecord->plockSet;
if(!p1lockSet) {

View File

@@ -536,7 +536,7 @@ static void dbRecordtypeFieldItem(char *name,char *value)
free((void *)value);
return;
}
yyerror("Illegal promptgroup. See guigroup.h for legal values");
yyerror("Illegal special value.");
return;
}
if(strcmp(name,"pp")==0) {

View File

@@ -53,6 +53,7 @@ of this distribution.
int dbStaticDebug = 0;
#define messagesize 100
#define RPCL_LEN 184
#define MAX_FIELD_NAME_LENGTH 20
long postfix(char *pinfix, char *ppostfix,short *perror);
static char *ppstring[5]={"NPP","PP","CA","CP","CPP"};
@@ -88,7 +89,8 @@ static char *promptOUTLINK[] = {
"NPP PP CA:",
"NMS or MS:"};
static char *promptFWDLINK[] = {
" PV Name:"};
" PV Name:",
" PP CA:"};
static char *promptVME_IO[] = {
" card:",
"signal:",
@@ -279,7 +281,6 @@ static long putParmString(char **pparm,char *pstring)
pstring++;
size = strlen(pstring) + 1;
if(size==1) return(0);
if(size>=MAX_STRING_SIZE) return(S_dbLib_strLen);
*pparm = dbCalloc(size, sizeof(char *));
strcpy(*pparm,pstring);
return(0);
@@ -1451,9 +1452,9 @@ long dbCopyRecord(DBENTRY *pdbentry,char *newRecordName,int overWriteOK)
return(0);
}
long dbFindField(DBENTRY *pdbentry,char *pfieldName)
long dbFindField(DBENTRY *pdbentry,char *pname)
{
dbRecordType *precordType = pdbentry->precordType;
dbRecordType *precordType = pdbentry->precordType;
dbRecordNode *precnode = pdbentry->precnode;
char *precord;
dbFldDes *pflddes;
@@ -1462,14 +1463,25 @@ long dbFindField(DBENTRY *pdbentry,char *pfieldName)
short *sortFldInd;
long status;
int compare;
char fieldName[MAX_FIELD_NAME_LENGTH];
char *pfieldName;
int ind;
if(!precordType) return(S_dbLib_recordTypeNotFound);
if(!precnode) return(S_dbLib_recNotFound);
precord = precnode->precord;
papsortFldName = precordType->papsortFldName;
sortFldInd = precordType->sortFldInd;
/*copy field name. Stop at null or blank or tab*/
pfieldName = &fieldName[0];
for(ind=0; ind<MAX_FIELD_NAME_LENGTH; ind++) {
if(*pname=='\0' || *pname==' ' || *pname=='\t') break;
*pfieldName++ = *pname++;
}
*pfieldName = '\0';
pfieldName = &fieldName[0];
/* check for default field name or VAL to be supplied */
if((*pfieldName==0) || (strcmp(pfieldName,"VAL")==0)) {
if((*pfieldName==0) || (strcmp(pfieldName,"VAL")==0) ) {
if(!(pflddes=precordType->pvalFldDes))
return(S_dbLib_recordTypeNotFound);
pdbentry->pflddes = pflddes;
@@ -1572,7 +1584,7 @@ char *dbGetString(DBENTRY *pdbentry)
if(plink->value.constantStr) {
strcpy(message,plink->value.constantStr);
} else {
strcpy(message,"0");
strcpy(message,"");
}
break;
case PV_LINK:
@@ -1665,12 +1677,22 @@ char *dbGetString(DBENTRY *pdbentry)
break;
case PV_LINK:
case CA_LINK:
case DB_LINK:
case DB_LINK: {
int ppind;
short pvlMask;
pvlMask = plink->value.pv_link.pvlMask;
if(pvlMask&pvlOptPP) ppind=1;
else if(pvlMask&pvlOptCA) ppind=2;
else ppind=0;
if(plink->value.pv_link.pvname)
strcpy(message,plink->value.pv_link.pvname);
else
strcpy(message,"");
strcat(message," ");
strcat(message,ppstring[ppind]);
break;
}
default :
return(NULL);
}
@@ -1778,6 +1800,8 @@ long dbPutString(DBENTRY *pdbentry,char *pstring)
if(!pstr || (int)strlen(pstr)<=0 ) {
if(plink->type==PV_LINK) dbCvtLinkToConstant(pdbentry);
if(plink->type!=CONSTANT) return(S_dbLib_badField);
free((void *)plink->value.constantStr);
plink->value.constantStr = NULL;
return(0);
}
switch(plink->type) {
@@ -1808,10 +1832,10 @@ long dbPutString(DBENTRY *pdbentry,char *pstring)
end = strchr(pstr,' ');
if(end) {
if(strstr(end,"NPP")) ppOpt = 0;
else if(strstr(end,"CPP")) ppOpt = pvlOptCPP;
else if(strstr(end,"PP")) ppOpt = pvlOptPP;
else if(strstr(end,"CA")) ppOpt = pvlOptCA;
else if(strstr(end,"CP")) ppOpt = pvlOptCP;
else if(strstr(end,"CPP")) ppOpt = pvlOptCPP;
else ppOpt = 0;
if(strstr(end,"NMS")) msOpt = 0;
else if(strstr(end,"MS")) msOpt = pvlOptMS;
@@ -2347,7 +2371,8 @@ int dbAllocForm(DBENTRY *psave)
status = mapLINKTtoFORMT(plink,plinkflddes,&linkType);
if(status) goto done;
nlines = formlines[linkType];
nbytes = sizeof(struct form) + 2*nlines*(sizeof(char *) + MAX_STRING_SIZE);
/*Dont know how to handle string size. Just use messagesize*/
nbytes = sizeof(struct form) + 2*nlines*(sizeof(char *) + messagesize);
pform = dbCalloc(1,nbytes);
pform->linkType = linkType;
psave->formpvt = pform;
@@ -2358,11 +2383,11 @@ int dbAllocForm(DBENTRY *psave)
pstr = (char *)(pform->verify) + nlines*sizeof(char *);
for(i=0; i<nlines; i++) {
pform->value[i] = pstr;
pstr += MAX_STRING_SIZE;
pstr += messagesize;
}
for(i=0; i<nlines; i++) {
pform->verify[i] = pstr;
pstr += MAX_STRING_SIZE;
pstr += messagesize;
}
done:
dbFinishEntry(pdbentry);
@@ -3016,6 +3041,8 @@ long dbCvtLinkToConstant(DBENTRY *pdbentry)
plink->value.constantStr =
dbCalloc(strlen(pflddes->initial)+1,sizeof(char));
strcpy(plink->value.constantStr,pflddes->initial);
} else {
plink->value.constantStr = NULL;
}
return(0);
default:

View File

@@ -107,6 +107,7 @@ SRCS.c += ../devAB1771IL.c
SRCS.c += ../devAB1771IR.c
SRCS.c += ../devAB1771IXE.c
SRCS.c += ../devAB1771OFE.c
SRCS.c += ../devABSLCDCM.c
SRCS.c += ../devABBINARY.c
SRCS.c += ../devABStatus.c
SRCS.c += ../devMpc.c

493
src/dev/devABSLCDCM.c Normal file
View File

@@ -0,0 +1,493 @@
/* devABSLCDCM.c */
/*
* Original Author: Ric Claus
* Current Author: Stephanie Allison
* Date: 1/25/96
*
* Experimental Physics and Industrial Control System (EPICS)
*
* Copyright 1996, the Regents of the University of California,
* the University of Chicago Board of Governors and The Board
* of Trustees of the Leland Stanford Junior University.
* All rights reserved.
*
* This software was produced under U.S. Government contracts:
* (W-7405-ENG-36) at the Los Alamos National Laboratory,
* (W-31-109-ENG-38) at Argonne National Laboratory, and
* (DE-AC03-76SF00515) at the Stanford Linear Accelerator Center.
*
* Initial development by:
* The PEP-II Low Level RF Group
* Positron Electron Project upgrade
* Stanford Linear Accelerator Center
*
* Co-developed with:
* The Controls and Automation Group (AT-8)
* Ground Test Accelerator
* Accelerator Technology Division
* Los Alamos National Laboratory
*
* and:
* The Controls and Computing Group
* Accelerator Systems Division
* Advanced Photon Source
* Argonne National Laboratory
*
* Modification Log:
* -----------------
* .01 1-25-96 rc Created from devABBINARY.c
* .02 6-03-96 saa Added ai/ao. Renamed to devABANALOG.c.
* ...
*/
#include <vxWorks.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <dbDefs.h>
#include <alarm.h>
#include <cvtTable.h>
#include <dbAccess.h>
#include <recSup.h>
#include <devSup.h>
#include <link.h>
#include <drvAb.h>
#include <dbCommon.h>
#include <longinRecord.h>
#include <longoutRecord.h>
#include <aiRecord.h>
#include <aoRecord.h>
typedef struct
{
void *drvPvt;
IOSCANPVT ioscanpvt;
}devPvt;
/* Create the dsets*/
LOCAL long ioinfo (int cmd, struct dbCommon *prec, IOSCANPVT *ppvt);
LOCAL long read_li (struct longinRecord *prec);
LOCAL long init_li (struct longinRecord *prec);
typedef struct
{
long number;
DEVSUPFUN report;
DEVSUPFUN init;
DEVSUPFUN init_record;
DEVSUPFUN get_ioint_info;
DEVSUPFUN read_li;
} ABLIDSET;
ABLIDSET devLiAbSclDcm = {5, NULL, NULL, init_li, ioinfo, read_li};
LOCAL long write_lo (struct longoutRecord *prec);
LOCAL long init_lo (struct longoutRecord *prec);
typedef struct
{
long number;
DEVSUPFUN report;
DEVSUPFUN init;
DEVSUPFUN init_record;
DEVSUPFUN get_ioint_info;
DEVSUPFUN write_dl;
} ABLODSET;
ABLODSET devLoAbSclDcm = {5, NULL, NULL, init_lo, NULL, write_lo};
LOCAL long read_ai(struct aiRecord *prec);
LOCAL long init_ai(struct aiRecord *prec);
LOCAL long linconv_ai(struct aiRecord *prec, int after);
typedef struct {
long number;
DEVSUPFUN report;
DEVSUPFUN init;
DEVSUPFUN init_record;
DEVSUPFUN get_ioint_info;
DEVSUPFUN read_ai;
DEVSUPFUN special_linconv;} ABAIDSET;
ABAIDSET devAiAbSclDcm={6, NULL, NULL, init_ai, ioinfo, read_ai, NULL};
LOCAL long write_ao(struct aoRecord *prec);
LOCAL long init_ao (struct aoRecord *prec);
LOCAL long linconv_ao(struct aoRecord *prec, int after);
typedef struct {
long number;
DEVSUPFUN report;
DEVSUPFUN init;
DEVSUPFUN init_record;
DEVSUPFUN get_ioint_info;
DEVSUPFUN write_ao;
DEVSUPFUN special_linconv;} ABAODSET;
ABAODSET devAoAAbSclDcm = {6, NULL, NULL, init_ao, NULL, write_ao, NULL};
LOCAL void devCallback (void * drvPvt)
{
devPvt *pdevPvt;
pdevPvt = (devPvt *) (*pabDrv->getUserPvt) (drvPvt);
if (!pdevPvt) return;
if (!pdevPvt->ioscanpvt) return;
scanIoRequest (pdevPvt->ioscanpvt);
}
LOCAL long ioinfo (int cmd,
struct dbCommon *prec,
IOSCANPVT *ppvt)
{
devPvt *pdevPvt;
pdevPvt = prec->dpvt;
if (!pdevPvt) return(0);
*ppvt = pdevPvt->ioscanpvt;
return (0);
}
LOCAL long read_li (struct longinRecord *prec)
{
devPvt *pdevPvt = (devPvt *) prec->dpvt;
void *drvPvt;
abStatus drvStatus;
short value[2];
if (!pdevPvt)
{
recGblSetSevr (prec, READ_ALARM, INVALID_ALARM);
return (2);
}
drvPvt = pdevPvt->drvPvt;
drvStatus = (*pabDrv->readBi) (drvPvt, (unsigned long *)value, 0x0000ffff);
if (drvStatus != abSuccess)
{
recGblSetSevr (prec, READ_ALARM, INVALID_ALARM);
return (2);
}
prec->val = (long)value[1];
return(0);
}
LOCAL long init_li (struct longinRecord *prec)
{
struct abio *pabio;
devPvt *pdevPvt;
abStatus drvStatus;
long status = 0;
void *drvPvt;
if (prec->inp.type != AB_IO)
{
recGblRecordError (S_db_badField, (void *) prec, "init_li: Bad INP field");
return (S_db_badField);
}
pabio = (struct abio *) &(prec->inp.value);
drvStatus = (*pabDrv->registerCard) (pabio->link, pabio->adapter, pabio->card,
typeBi, "BINARY", devCallback, &drvPvt);
switch (drvStatus)
{
case abSuccess :
pdevPvt = (devPvt *) (*pabDrv->getUserPvt) (drvPvt);
prec->dpvt = pdevPvt;
break;
case abNewCard :
pdevPvt = calloc (1, sizeof (devPvt));
pdevPvt->drvPvt = drvPvt;
prec->dpvt = pdevPvt;
(*pabDrv->setUserPvt) (drvPvt, (void *) pdevPvt);
scanIoInit (&pdevPvt->ioscanpvt);
drvStatus = (*pabDrv->setNbits) (drvPvt, abBit16);
if (drvStatus != abSuccess)
{
status = S_db_badField;
recGblRecordError (status, (void *) prec, "init_li: setNbits");
}
break;
default:
status = S_db_badField;
recGblRecordError (status, (void *)prec, "init_li: registerCard");
break;
}
return (status);
}
LOCAL long write_lo (struct longoutRecord *prec)
{
devPvt *pdevPvt = (devPvt *) prec->dpvt;
void *drvPvt;
abStatus drvStatus;
if (!pdevPvt)
{
recGblSetSevr (prec, WRITE_ALARM, INVALID_ALARM);
return (0);
}
drvPvt = pdevPvt->drvPvt;
drvStatus = (*pabDrv->updateBo) (drvPvt, prec->val, 0x0000ffff);
if (drvStatus != abSuccess)
{
recGblSetSevr (prec, WRITE_ALARM, INVALID_ALARM);
}
return(0);
}
LOCAL long init_lo (struct longoutRecord *prec)
{
struct abio *pabio;
devPvt *pdevPvt;
abStatus drvStatus;
long status = 0;
void *drvPvt;
short value[2];
if (prec->out.type != AB_IO)
{
recGblRecordError (S_db_badField, (void *) prec, "init_lo: Bad OUT field");
return (S_db_badField);
}
pabio = (struct abio *) &(prec->out.value);
drvStatus = (*pabDrv->registerCard) (pabio->link, pabio->adapter, pabio->card,
typeBo, "BINARY", NULL, &drvPvt);
switch (drvStatus)
{
case abSuccess :
pdevPvt = (devPvt *) (*pabDrv->getUserPvt) (drvPvt);
prec->dpvt = pdevPvt;
break;
case abNewCard :
pdevPvt = calloc (1, sizeof (devPvt));
pdevPvt->drvPvt = drvPvt;
prec->dpvt = pdevPvt;
(*pabDrv->setUserPvt) (drvPvt, (void *) pdevPvt);
drvStatus = (*pabDrv->setNbits) (drvPvt, abBit16);
if (drvStatus != abSuccess)
{
status = S_db_badField;
recGblRecordError (status, (void *) prec, "init_lo: setNbits");
return (status);
}
break;
default:
status = S_db_badField;
printf ("init_lo: %s\n", abStatusMessage[drvStatus]);
recGblRecordError (status, (void *) prec, "init_lo: registerCard");
return (status);
}
drvStatus = (*pabDrv->readBo) (drvPvt, (unsigned long *)value, 0x0000ffff);
if (drvStatus == abSuccess)
{
prec->val = (long)value[1];
status = 0;
}
else
{
status = 2;
}
return (status);
}
LOCAL long read_ai (struct aiRecord *prec)
{
devPvt *pdevPvt = (devPvt *) prec->dpvt;
void *drvPvt;
abStatus drvStatus;
short value[2];
if (!pdevPvt)
{
recGblSetSevr (prec, READ_ALARM, INVALID_ALARM);
return (2);
}
drvPvt = pdevPvt->drvPvt;
drvStatus = (*pabDrv->readBi) (drvPvt, (unsigned long *)value, 0x0000ffff);
if (drvStatus != abSuccess)
{
recGblSetSevr (prec, READ_ALARM, INVALID_ALARM);
return (2);
}
prec->rval = (long)value[1];
return(0);
}
LOCAL long linconv_ai(struct aiRecord *prec, int after)
{
if(!after) return(0);
/* set linear conversion slope*/
prec->eslo = (prec->eguf -prec->egul)/65535.0;
return(0);
}
LOCAL long init_ai (struct aiRecord *prec)
{
struct abio *pabio;
devPvt *pdevPvt;
abStatus drvStatus;
long status = 0;
void *drvPvt;
if (prec->inp.type != AB_IO)
{
recGblRecordError (S_db_badField, (void *) prec, "init_ai: Bad INP field");
return (S_db_badField);
}
pabio = (struct abio *) &(prec->inp.value);
drvStatus = (*pabDrv->registerCard) (pabio->link, pabio->adapter, pabio->card,
typeBi, "BINARY", devCallback, &drvPvt);
switch (drvStatus)
{
case abSuccess :
pdevPvt = (devPvt *) (*pabDrv->getUserPvt) (drvPvt);
prec->dpvt = pdevPvt;
break;
case abNewCard :
pdevPvt = calloc (1, sizeof (devPvt));
pdevPvt->drvPvt = drvPvt;
prec->dpvt = pdevPvt;
(*pabDrv->setUserPvt) (drvPvt, (void *) pdevPvt);
scanIoInit (&pdevPvt->ioscanpvt);
drvStatus = (*pabDrv->setNbits) (drvPvt, abBit16);
if (drvStatus != abSuccess)
{
status = S_db_badField;
recGblRecordError (status, (void *) prec, "init_ai: setNbits");
}
break;
default:
status = S_db_badField;
recGblRecordError (status, (void *)prec, "init_ai: registerCard");
break;
}
return (status);
}
LOCAL long write_ao (struct aoRecord *prec)
{
devPvt *pdevPvt = (devPvt *) prec->dpvt;
void *drvPvt;
abStatus drvStatus;
if (!pdevPvt)
{
recGblSetSevr (prec, WRITE_ALARM, INVALID_ALARM);
return (0);
}
drvPvt = pdevPvt->drvPvt;
drvStatus = (*pabDrv->updateBo) (drvPvt, prec->rval, 0x0000ffff);
if (drvStatus != abSuccess)
{
recGblSetSevr (prec, WRITE_ALARM, INVALID_ALARM);
}
return(0);
}
LOCAL long linconv_ao(struct aoRecord *prec, int after)
{
if(!after) return(0);
/* set linear conversion slope*/
prec->eslo = (prec->eguf -prec->egul)/65535.0;
return(0);
}
LOCAL long init_ao (struct aoRecord *prec)
{
struct abio *pabio;
devPvt *pdevPvt;
abStatus drvStatus;
long status = 0;
void *drvPvt;
short value[2];
if (prec->out.type != AB_IO)
{
recGblRecordError (S_db_badField, (void *) prec, "init_ao: Bad OUT field");
return (S_db_badField);
}
pabio = (struct abio *) &(prec->out.value);
drvStatus = (*pabDrv->registerCard) (pabio->link, pabio->adapter, pabio->card,
typeBo, "BINARY", NULL, &drvPvt);
switch (drvStatus)
{
case abSuccess :
pdevPvt = (devPvt *) (*pabDrv->getUserPvt) (drvPvt);
prec->dpvt = pdevPvt;
break;
case abNewCard :
pdevPvt = calloc (1, sizeof (devPvt));
pdevPvt->drvPvt = drvPvt;
prec->dpvt = pdevPvt;
(*pabDrv->setUserPvt) (drvPvt, (void *) pdevPvt);
drvStatus = (*pabDrv->setNbits) (drvPvt, abBit16);
if (drvStatus != abSuccess)
{
status = S_db_badField;
recGblRecordError (status, (void *) prec, "init_ao: setNbits");
return (status);
}
break;
default:
status = S_db_badField;
printf ("init_ao: %s\n", abStatusMessage[drvStatus]);
recGblRecordError (status, (void *) prec, "init_ao: registerCard");
return (status);
}
drvStatus = (*pabDrv->readBo) (drvPvt, (unsigned long *)value, 0x0000ffff);
if (drvStatus == abSuccess)
{
prec->rval = (long)value[1];
status = 0;
}
else
{
status = 2;
}
return (status);
}

View File

@@ -1130,7 +1130,7 @@ void at5vxi_stat(
work = ((uint32_t)pdd->bio[1]) << (sizeof(uint16_t)*NBBY);
work |= pdd->bio[0];
printf("\tBIO: value %x\n", work);
printf("\tBIO: value %lx\n", (unsigned long) work);
}
for(channel=0; channel<NELEMENTS(pconfig->tv); channel++){

View File

@@ -2507,7 +2507,7 @@ unsigned servant_area
}
else{
printf(
"VXI resman: gd resp %x\n",
"VXI resman: gd resp %lx\n",
response);
}
}
@@ -2842,7 +2842,7 @@ VXIE *pvxie
A32_size = pvxie->A32_size;
psubvxie = (VXIE *) &pvxie->extenders.node;
while(psubvxie = (VXIE *) ellNext((ELLNODE *)psubvxie)){
while( (psubvxie = (VXIE *) ellNext((ELLNODE *)psubvxie)) ){
psubvxie->A24_base = A24_base;
psubvxie->A24_size = A24_size;
@@ -3235,7 +3235,7 @@ EPVXISTAT epvxiDeviceList(void)
if(pmxidi->msg_dev_online){
printf("msg online, ");
}
printf("driver ID %d, ", pmxidi->driverID);
printf("driver ID %ld, ", pmxidi->driverID);
if(taskIdVerify(pmxidi->taskID)>=0){
printf( "opened by task %s, ",
taskName(pmxidi->taskID));
@@ -4577,19 +4577,19 @@ LOCAL void epvxiExtenderPrint(VXIE *pvxie)
}
if(pvxie->A24_mapped){
printf("\tA24 window base=0x%08X size=0x%08X\n",
printf("\tA24 window base=0x%08lX size=0x%08lX\n",
pvxie->A24_base,
pvxie->A24_size);
}
if(pvxie->A32_mapped){
printf("\tA32 window base=0x%08X size=0x%08X\n",
printf("\tA32 window base=0x%08lX size=0x%08lX\n",
pvxie->A32_base,
pvxie->A32_size);
}
psubvxie = (VXIE *) &pvxie->extenders.node;
while(psubvxie = (VXIE *) ellNext((ELLNODE *)psubvxie)){
while( (psubvxie = (VXIE *) ellNext((ELLNODE *)psubvxie)) ){
epvxiExtenderPrint(psubvxie);
}
}

View File

@@ -47,6 +47,8 @@
static char *sccsId = "@(#)drvEpvxiMsg.c 1.15\t8/27/93";
#include <string.h>
#include <vxWorks.h>
#include <iv.h>
#include <semLib.h>
@@ -204,8 +206,8 @@ EPVXISTAT vxi_msg_test(
return status;
}
buf[count] = NULL;
printf("%s %d\n", buf,count);
buf[count] = '\0';
printf("%s %ld\n", buf,count);
status = epvxiWrite(la, "*TST?", 5, &count, epvxiWriteOptNone);
if(status != VXI_SUCCESS){
@@ -216,8 +218,8 @@ EPVXISTAT vxi_msg_test(
return status;
}
buf[count] = NULL;
printf("%s %d\n", buf, count);
buf[count] = '\0';
printf("%s %ld\n", buf, count);
return VXI_SUCCESS;
}
@@ -246,7 +248,7 @@ EPVXISTAT vxi_msg_print_id(
return status;
}
buf[count] = NULL;
buf[count] = '\0';
printf(" %s ", buf);
return VXI_SUCCESS;
@@ -336,7 +338,7 @@ unsigned long cmd
}
if(pvximdi->trace){
printf( "VXI Trace: (la=0X%X) Cmd -> %x\n",
printf( "VXI Trace: (la=0X%X) Cmd -> %lx\n",
la,
cmd);
}
@@ -392,7 +394,7 @@ unsigned long *presp
}
if(pvximdi->trace){
printf( "VXI Trace: (la=0X%X) Query -> %x\n",
printf( "VXI Trace: (la=0X%X) Query -> %lx\n",
la,
*presp);
}
@@ -706,7 +708,7 @@ EPVXISTAT epvxiReadSlowHandshake(
/*
* append the NULL
*/
*pbuf = NULL;
*pbuf = '\0';
if(function_status == S_epvxi_protocolError){
return fetch_protocol_error(la);
@@ -1059,7 +1061,7 @@ printf("mb device has response gen\n");
resp);
return VXI_SUCCESS;
}
printf("sent ctrl resp (la=%d) (cmd=%x)\n", la, cmd);
printf("sent ctrl resp (la=%d) (cmd=%lx)\n", la, cmd);
printf("synchronized msg based device is ready!\n");
@@ -1256,7 +1258,7 @@ LOCAL EPVXISTAT vxiAttemptAsyncModeControl(
la);
return status;
}
printf("sent id cmdr (la=0X%X) (cmd=%x)\n", la, tmpcmd);
printf("sent id cmdr (la=0X%X) (cmd=%lx)\n", la, tmpcmd);
}
status = epvxiCmdQuery(
@@ -1285,7 +1287,7 @@ printf("sent id cmdr (la=0X%X) (cmd=%x)\n", la, tmpcmd);
resp);
return status;
}
printf("sent asynch mode control (la=%d) (cmd=%x)\n",la,cmd);
printf("sent asynch mode control (la=%d) (cmd=%lx)\n",la,cmd);
if(cmd & MBC_AMC_RESP_INT_ENABLE){
@@ -1500,11 +1502,11 @@ void vxiMsgInt(
logMsg (
"%s: vxiMsgInt(): msg int to ukn or closed dev\n",
(int)__FILE__,
NULL,
NULL,
NULL,
NULL,
NULL);
0,
0,
0,
0,
0);
}
}
@@ -1526,10 +1528,10 @@ int16_t signal
logMsg( "%s: VXI event was ignored %x\n",
(int)__FILE__,
signal,
NULL,
NULL,
NULL,
NULL);
0,
0,
0,
0);
}
else{
vxiMsgInt(signal_la);

View File

@@ -40,6 +40,7 @@ static char *sccsId = "@(#)drvHpe1445a.c 1.5\t8/27/93";
#include <vxWorks.h>
#include <stdioLib.h>
#include <taskLib.h>
#include <string.h>
#include <module_types.h>
#include <fast_lock.h>
@@ -1004,14 +1005,13 @@ unsigned long npoints
return s;
}
sprintf(pc->buf, "source:list:segment:define %u", npoints);
sprintf(pc->buf, "source:list:segment:define %lu", npoints);
s = hpe1445aWrite(la, pc->buf);
if(s){
return s;
}
sprintf( pc->buf,
"source:arbitrary:download VXI,%s%s,%d",
"source:arbitrary:download VXI,%s%s,%lu",
SEGMENT_NAME_PREFIX,
pWaveformName,
npoints);

View File

@@ -0,0 +1,52 @@
#
# Author: Jeff Hill
# Date: 8/96
#
# $Id$
#
# $Log$
# Revision 1.1 1996/09/04 20:59:40 jhill
# installed
#
VPATH=.:..
TOP= ../../..
include $(TOP)/config/CONFIG_BASE
DEPENDS_RULE.cc = -$(COMPILE.cc) -xM $(SRCS.cc) >> .DEPENDS
USR_LDFLAGS = -L$(EPICS_EXTENSIONS_LIB) -L.
USR_CFLAGS = -L$(EPICS_EXTENSIONS_LIB) -L.
SRCS.cc = ../aitGen.c ../aitTypes.c ../aitHelpers.cc \
../gdd.cc ../gddAppDefs.cc ../gddAppTable.cc ../gddNewDel.cc \
../gddTest.cc ../dbMapper.cc
LIBOBJS = gdd.o gddAppTable.o gddNewDel.o gddAppDefs.o \
aitTypes.o aitConvert.o aitHelpers.o dbMapper.o
LIBNAME = libgdd.o
include $(TOP)/config/RULES.Vx
# cannot generate dependencies for aitConvert automatically
aitConvert.o: aitConvert.cc aitConvert.h aitConvertGenerated.cc aitTypes.h
aitConvertGenerated.cc: ../O.$(HOST_ARCH)/aitGen aitTypes.h
../O.$(HOST_ARCH)/aitGen
# cannot generate dependencies for dbMapper.o automatically
dbMapper.o: ../dbMapper.cc gdd.h gddAppTable.h dbMapper.h gddApps.h aitTypes.h
$(COMPILE.cc) $<
gddApps.h: ../O.$(HOST_ARCH)/genApps
../O.$(HOST_ARCH)/genApps $@
clean::
/bin/rm -f aitConvertGenerated.cc aitGen

View File

@@ -5,6 +5,9 @@
// $Id$
//
// $Log$
// Revision 1.2 1996/08/13 15:07:42 jbk
// changes for better string manipulation and fixes for the units field
//
// Revision 1.1 1996/06/25 19:11:28 jbk
// new in EPICS base
//
@@ -72,7 +75,7 @@ static void aitConvertStringFixedString(void* d,const void* s,aitIndex c)
aitString* out = (aitString*)d;
aitFixedString* in = (aitFixedString*)s;
for(i=0;i<c;i++) out[i].copy(in[i].fixed_string);
for(i=0;i<c;i++) out[i].installString(in[i].fixed_string);
}
static void aitConvertFixedStringString(void* d,const void* s,aitIndex c)

View File

@@ -5,6 +5,12 @@
// $Id$
//
// $Log$
// Revision 1.4 1996/08/22 21:05:38 jbk
// More fixes to make strings and fixed string work better.
//
// Revision 1.3 1996/08/09 02:28:08 jbk
// rewrite of aitString class - more intuitive now, I think
//
// Revision 1.2 1996/08/06 19:14:06 jbk
// Fixes to the string class.
// Changes units field to a aitString instead of aitInt8.
@@ -52,14 +58,17 @@ aitIndex aitString::compact(aitString* array, aitIndex arraySize,
// copy the array first
pos=sizeof(aitString)*arraySize;
if(bufSize<pos) return 0;
memcpy(ptr,(char*)array,pos);
for(i=0;i<arraySize;i++) str[i].init();
for(i=0;i<arraySize;i++)
{
if(str[i].string())
if((pos+str[i].length())>bufSize) break; // quick exit from loop
if(array[i].string())
{
memcpy(&ptr[pos],str[i].string(),str[i].length()+1); // include NULL
str[i]=&ptr[pos];
memcpy(&ptr[pos],array[i].string(),array[i].length()+1);
str[i].force(&ptr[pos]);
str[i].len=array[i].length();
pos+=str[i].length()+1;
}
}

View File

@@ -8,6 +8,10 @@
* $Id$
*
* $Log$
* Revision 1.6 1996/08/14 12:30:10 jbk
* fixes for converting aitString to aitInt8* and back
* fixes for managing the units field for the dbr types
*
* Revision 1.5 1996/08/12 15:37:46 jbk
* Re-added the installString() function I took out.
*
@@ -185,18 +189,26 @@ public:
int copy(const aitString* p);
int copy(const aitString& p);
int copy(const char* p);
void installString(char* p) { copy(p); }
int installString(aitString* p);
int installString(aitString& p);
int installString(char* p);
int installString(const aitString* p);
int installString(const aitString& p);
int installString(const char* p);
// set data in the aitString and retrieve data from the aitString
void replaceData(const char* p);
void replaceData(const aitString* p);
void replaceData(aitString& p);
void replaceData(const aitString& p);
void extractString(char* to_here);
// special function to change the string - internal use with gdd library
void force(char* x) { str=x; }
void force(unsigned char* x) { str=(char*)x; }
void force(unsigned long x) { str=(char*)x; }
void forceConstant(void) { type=aitStrConst; }
void init(void);
// take the aitString array, and put it and all the string into buf,
@@ -279,9 +291,24 @@ inline void aitString::replaceData(const aitString* p)
{ if(p && str) strncpy(str,p->string(),len); }
inline void aitString::replaceData(aitString& p)
{ if(str) strncpy(str,p.string(),len); }
inline void aitString::replaceData(const aitString& p)
{ if(str) strncpy(str,p.string(),len); }
inline void aitString::extractString(char* p)
{ if(p && str) strcpy(p,str); }
inline int aitString::installString(const char* p)
{ int rc=0; if(isConstant()) replaceData(p); else rc=copy(p); return rc; }
inline int aitString::installString(char* p)
{ int rc=0; if(isConstant()) replaceData(p); else rc=copy(p); return rc; }
inline int aitString::installString(aitString* p)
{ int rc=0; if(isConstant()) replaceData(p); else rc=copy(p); return rc; }
inline int aitString::installString(aitString& p)
{ int rc=0; if(isConstant()) replaceData(p); else rc=copy(p); return rc; }
inline int aitString::installString(const aitString* p)
{ int rc=0; if(isConstant()) replaceData(p); else rc=copy(p); return rc; }
inline int aitString::installString(const aitString& p)
{ int rc=0; if(isConstant()) replaceData(p); else rc=copy(p); return rc; }
inline aitString& aitString::operator=(const aitString& p)
{ this->copy(p); return *this; }
inline aitString& aitString::operator=(const aitString* p)

View File

@@ -8,6 +8,9 @@
* $Id$
*
* $Log$
* Revision 1.1 1996/06/25 19:11:33 jbk
* new in EPICS base
*
*
* *Revision 1.2 1996/06/17 15:24:07 jbk
* *many mods, string class corrections.
@@ -68,7 +71,7 @@ typedef struct {
#define aitTotal 13
#define aitFirst aitEnumInvalid
#define aitLast aitEnumContainer
#define aitValid(x) ((x)<=aitLast)
#define aitValid(x) ((x)<=aitLast && (x)>aitFirst)
/* all conversion types */
#define aitConvertTotal 11

View File

@@ -4,6 +4,13 @@
// $Id$
//
// $Log$
// Revision 1.12 1996/08/22 21:05:43 jbk
// More fixes to make strings and fixed string work better.
//
// Revision 1.11 1996/08/14 12:30:12 jbk
// fixes for converting aitString to aitInt8* and back
// fixes for managing the units field for the dbr types
//
// Revision 1.10 1996/08/13 15:07:45 jbk
// changes for better string manipulation and fixes for the units field
//
@@ -162,7 +169,7 @@ static int mapGddToString(void* v, gdd* dd) {
dbx=(aitFixedString*)dd->dataPointer();
int len = dd->getDataSizeElements();
if(dbx!=db) dd->getConvert(*db);
if(dbx!=db) dd->get(db);
return len;
}
@@ -373,7 +380,7 @@ static int mapStsGddToString(void* v, gdd* dd)
dbx=(aitFixedString*)dd->dataPointer();
// copy string into user buffer for now if not the same as one in gdd
if(dbx!=dbv) dd->getConvert(*dbv);
if(dbx!=dbv) dd->get(dbv);
dd->getStatSevr(db->status,db->severity);
return dd->getDataSizeElements();
}
@@ -514,7 +521,7 @@ static int mapTimeGddToString(void* v, gdd* dd)
else
dbx=(aitFixedString*)dd->dataPointer();
if(dbv!=dbx) dd->getConvert(*dbv);
if(dbv!=dbx) dd->get(dbv);
dd->getStatSevr(db->status,db->severity);
dd->getTimeStamp((aitTimeStamp*)&db->stamp);
@@ -643,7 +650,7 @@ static gdd* mapGraphicShortToGdd(void* v, aitIndex count)
aitString* str=NULL;
dd[gddAppTypeIndex_dbr_gr_short_units].getRef(str);
str->copy(db->units);
str->installString(db->units);
dd[gddAppTypeIndex_dbr_gr_short_graphicLow]=db->lower_disp_limit;
dd[gddAppTypeIndex_dbr_gr_short_graphicHigh]=db->upper_disp_limit;
@@ -675,7 +682,7 @@ static gdd* mapControlShortToGdd(void* v, aitIndex count)
aitString* str = NULL;
dd[gddAppTypeIndex_dbr_ctrl_short_units].getRef(str);
str->copy(db->units);
str->installString(db->units);
dd[gddAppTypeIndex_dbr_ctrl_short_graphicLow]=db->lower_disp_limit;
dd[gddAppTypeIndex_dbr_ctrl_short_graphicHigh]=db->upper_disp_limit;
@@ -768,7 +775,7 @@ static gdd* mapGraphicFloatToGdd(void* v, aitIndex count)
aitString* str = NULL;
dd[gddAppTypeIndex_dbr_gr_float_units].getRef(str);
str->copy(db->units);
str->installString(db->units);
dd[gddAppTypeIndex_dbr_gr_float_precision]=db->precision;
dd[gddAppTypeIndex_dbr_gr_float_graphicLow]=db->lower_disp_limit;
@@ -801,7 +808,7 @@ static gdd* mapControlFloatToGdd(void* v, aitIndex count)
aitString* str = NULL;
dd[gddAppTypeIndex_dbr_ctrl_float_units].getRef(str);
str->copy(db->units);
str->installString(db->units);
dd[gddAppTypeIndex_dbr_ctrl_float_precision]=db->precision;
dd[gddAppTypeIndex_dbr_ctrl_float_graphicLow]=db->lower_disp_limit;
@@ -896,18 +903,33 @@ static gdd* mapGraphicEnumToGdd(void* v, aitIndex /*count*/)
gdd& menu = dd[gddAppTypeIndex_dbr_gr_enum_enums];
aitFixedString* str = menu;
aitFixedString* f = (aitFixedString*)db->strs;
aitIndex sz,i;
// int i;
// old way using aitString menu
// for(i=0;i<db->no_str;i++) str[i]=((const char*)&(db->strs[i][0]));
menu.putRef(f);
menu.setBound(0,0,db->no_str);
vdd.setStatSevr(db->status,db->severity);
if(menu.dataPointer()==NULL || !menu.isAtomic())
{
// need to copy the menu chunk from dbr to aitFixedString chunk
menu.setDimension(1);
sz=db->no_str;
str=new aitFixedString[db->no_str];
menu.putRef(str,new gddDestructor);
}
else
{
if((sz=menu.getDataSizeElements())>db->no_str)
sz=db->no_str;
}
for(i=0;i<sz;i++) strcpy(str[i].fixed_string,&(db->strs[i][0]));
menu.setBound(0,0,sz);
// should always be a scaler
if(vdd.dimension()) vdd.clear();
vdd=db->value;
vdd.setStatSevr(db->status,db->severity);
return dd;
}
@@ -919,18 +941,33 @@ static gdd* mapControlEnumToGdd(void* v, aitIndex /*count*/)
gdd& vdd = dd[gddAppTypeIndex_dbr_ctrl_enum_value];
aitFixedString* str = menu;
aitFixedString* f = (aitFixedString*)db->strs;
aitIndex sz,i;
// int i;
// old way using aitString menu
// for(i=0;i<db->no_str;i++) str[i]=((const char*)&(db->strs[i][0]));
menu.putRef(f);
menu.setBound(0,0,db->no_str);
vdd.setStatSevr(db->status,db->severity);
if(menu.dataPointer()==NULL || !menu.isAtomic())
{
// need to copy the menu chunk from dbr to aitFixedString chunk
menu.setDimension(1);
sz=db->no_str;
str=new aitFixedString[db->no_str];
menu.putRef(str,new gddDestructor);
}
else
{
if((sz=menu.getDataSizeElements())>db->no_str)
sz=db->no_str;
}
for(i=0;i<sz;i++) strcpy(str[i].fixed_string,&(db->strs[i][0]));
menu.setBound(0,0,sz);
// should always be a scaler
if(vdd.dimension()) vdd.clear();
vdd=db->value;
vdd.setStatSevr(db->status,db->severity);
return dd;
}
@@ -986,7 +1023,7 @@ static gdd* mapGraphicCharToGdd(void* v, aitIndex count)
aitString* str = NULL;
dd[gddAppTypeIndex_dbr_gr_char_units].getRef(str);
str->copy(db->units);
str->installString(db->units);
dd[gddAppTypeIndex_dbr_gr_char_graphicLow]=db->lower_disp_limit;
dd[gddAppTypeIndex_dbr_gr_char_graphicHigh]=db->upper_disp_limit;
@@ -1018,7 +1055,7 @@ static gdd* mapControlCharToGdd(void* v, aitIndex count)
aitString* str = NULL;
dd[gddAppTypeIndex_dbr_ctrl_char_units].getRef(str);
str->copy(db->units);
str->installString(db->units);
dd[gddAppTypeIndex_dbr_ctrl_char_graphicLow]=db->lower_disp_limit;
dd[gddAppTypeIndex_dbr_ctrl_char_graphicHigh]=db->upper_disp_limit;
@@ -1111,7 +1148,7 @@ static gdd* mapGraphicLongToGdd(void* v, aitIndex count)
aitString* str = NULL;
dd[gddAppTypeIndex_dbr_gr_long_units].getRef(str);
str->copy(db->units);
str->installString(db->units);
dd[gddAppTypeIndex_dbr_gr_long_graphicLow]=db->lower_disp_limit;
dd[gddAppTypeIndex_dbr_gr_long_graphicHigh]=db->upper_disp_limit;
@@ -1143,7 +1180,7 @@ static gdd* mapControlLongToGdd(void* v, aitIndex count)
aitString* str = NULL;
dd[gddAppTypeIndex_dbr_ctrl_long_units].getRef(str);
str->copy(db->units);
str->installString(db->units);
dd[gddAppTypeIndex_dbr_ctrl_long_graphicLow]=db->lower_disp_limit;
dd[gddAppTypeIndex_dbr_ctrl_long_graphicHigh]=db->upper_disp_limit;
@@ -1236,7 +1273,7 @@ static gdd* mapGraphicDoubleToGdd(void* v, aitIndex count)
aitString* str = NULL;
dd[gddAppTypeIndex_dbr_gr_double_units].getRef(str);
str->copy(db->units);
str->installString(db->units);
dd[gddAppTypeIndex_dbr_gr_double_precision]=db->precision;
dd[gddAppTypeIndex_dbr_gr_double_graphicLow]=db->lower_disp_limit;
@@ -1269,7 +1306,7 @@ static gdd* mapControlDoubleToGdd(void* v, aitIndex count)
aitString* str = NULL;
dd[gddAppTypeIndex_dbr_ctrl_double_units].getRef(str);
str->copy(db->units);
str->installString(db->units);
dd[gddAppTypeIndex_dbr_ctrl_double_precision]=db->precision;
dd[gddAppTypeIndex_dbr_ctrl_double_graphicLow]=db->lower_disp_limit;

View File

@@ -4,6 +4,16 @@
// $Id$
//
// $Log$
// Revision 1.10 1996/08/23 20:29:36 jbk
// completed fixes for the aitString and fixed string management
//
// Revision 1.9 1996/08/22 21:05:40 jbk
// More fixes to make strings and fixed string work better.
//
// Revision 1.8 1996/08/14 12:30:14 jbk
// fixes for converting aitString to aitInt8* and back
// fixes for managing the units field for the dbr types
//
// Revision 1.7 1996/08/13 15:07:46 jbk
// changes for better string manipulation and fixes for the units field
//
@@ -63,6 +73,23 @@ gdd_NEWDEL_NEW(gdd)
gdd_NEWDEL_DEL(gdd)
gdd_NEWDEL_STAT(gdd)
// -------------------------- Error messages -------------------------
char* gddErrorMessages[]=
{
"Invalid",
"TypeMismatch",
"NotAllowed",
"AlreadyDefined",
"NewFailed",
"OutOfBounds",
"AtLimit",
"NotDefined",
"NotSupported",
"Overflow",
"Underflow"
};
// --------------------------The gddBounds functions-------------------
// gddBounds::gddBounds(void) { first=0; count=0; }
@@ -122,6 +149,7 @@ void gdd::init(int app, aitEnum prim, int dimen)
flags=0;
bounds=NULL;
setData(NULL);
setStatSevr(0u,0u);
if(dim)
{
@@ -172,7 +200,7 @@ gdd::~gdd(void)
destruct->destroy(dataAddress());
else
{
aitString* s = (aitString*)&data;
aitString* s = (aitString*)dataAddress();
s->clear();
}
}
@@ -180,10 +208,10 @@ gdd::~gdd(void)
else if(isContainer())
{
if(destruct)
destruct->destroy(voidData());
destruct->destroy(dataPointer());
else
{
for(dd=(gdd*)voidData();dd;)
for(dd=(gdd*)dataPointer();dd;)
{
temp=dd;
dd=dd->next();
@@ -194,7 +222,7 @@ gdd::~gdd(void)
}
else
{
if(destruct) destruct->destroy(voidData());
if(destruct) destruct->destroy(dataPointer());
if(bounds) freeBounds();
}
}
@@ -213,13 +241,35 @@ void gdd::freeBounds(void)
}
bounds=NULL;
}
dim=0; // Reflect the fact that this now a scalar? Bounds and dim
// should be tightly coupled, so no bounds means no dimension.
}
void gdd::setDimension(int d)
{
if(dim!=d)
{
freeBounds();
dim=(aitUint8)d;
switch(dim)
{
case 0: break;
case 1: bounds=(gddBounds*)new gddBounds1D; bounds->set(0,0); break;
case 2: bounds=(gddBounds*)new gddBounds2D; break;
case 3: bounds=(gddBounds*)new gddBounds3D; break;
default: bounds=(gddBounds*)new gddBounds[dim]; break;
}
}
}
gddStatus gdd::registerDestructor(gddDestructor* dest)
{
// this is funky, will not register a destructor if one is present
if(destruct)
{
gddAutoPrint("gdd::registerDestructor()",gddErrorAlreadyDefined);
return gddErrorAlreadyDefined;
}
else
return replaceDestructor(dest);
}
@@ -241,26 +291,34 @@ gddStatus gdd::genCopy(aitEnum t, const void* d)
gddStatus rc=0;
if(isScalar())
aitConvert(primitiveType(),&data,t,d,1);
aitConvert(primitiveType(),dataAddress(),t,d,1);
else if(isAtomic())
{
if(!voidData())
if(!dataPointer())
{
sz=DescribedDataSizeBytes();
sz=describedDataSizeBytes();
if((buf=new aitInt8[sz])==NULL)
{
gddAutoPrint("gdd::genCopy()",gddErrorNewFailed);
rc=gddErrorNewFailed;
}
else
{
setData(buf);
destruct=new gddDestructor;
aitConvert(primitiveType(),voidData(),t,d,getDataSizeElements());
aitConvert(primitiveType(),dataPointer(),t,d,
getDataSizeElements());
}
}
else
aitConvert(primitiveType(),voidData(),t,d,getDataSizeElements());
aitConvert(primitiveType(),dataPointer(),t,d,
getDataSizeElements());
}
else
{
gddAutoPrint("gdd::genCopy()",gddErrorTypeMismatch);
rc=gddErrorTypeMismatch;
}
return rc;
}
@@ -279,7 +337,10 @@ gddStatus gdd::changeType(int app,aitEnum prim)
setPrimType(prim);
}
else
{
gddAutoPrint("gdd::changeType()",gddErrorTypeMismatch);
rc=gddErrorTypeMismatch;
}
return rc;
}
@@ -290,7 +351,10 @@ gddStatus gdd::setBound(unsigned index_dim, aitIndex first, aitIndex count)
if(index_dim<dimension())
bounds[index_dim].set(first,count);
else
{
gddAutoPrint("gdd::setBound()",gddErrorOutOfBounds);
rc=gddErrorOutOfBounds;
}
return rc;
}
@@ -300,7 +364,10 @@ gddStatus gdd::getBound(unsigned index_dim, aitIndex& first, aitIndex& count)
if(index_dim<dimension())
bounds[index_dim].get(first,count);
else
{
gddAutoPrint("gdd::getBound()",gddErrorOutOfBounds);
rc=gddErrorOutOfBounds;
}
return rc;
}
@@ -314,7 +381,10 @@ gddStatus gdd::copyStuff(gdd* dd,int ctype)
// blow me out quickly here
if(isFlat()||isManaged())
{
gddAutoPrint("gdd::copyStuff()",gddErrorNotAllowed);
return gddErrorNotAllowed;
}
clear();
@@ -328,7 +398,7 @@ gddStatus gdd::copyStuff(gdd* dd,int ctype)
{
pdd=new gdd(ndd->applicationType(),
ndd->primitiveType(),ndd->dimension());
pdd->setNext((gdd*)voidData());
pdd->setNext((gdd*)dataPointer());
setData(pdd);
bounds->setSize(bounds->size()+1);
pdd->copyStuff(ndd,ctype);
@@ -354,11 +424,14 @@ gddStatus gdd::copyStuff(gdd* dd,int ctype)
if(array=new aitUint8[a_size])
{
destruct=new gddDestructor;
memcpy(array,dd->voidData(),a_size);
memcpy(array,dd->dataPointer(),a_size);
setData(array);
}
else
{
gddAutoPrint("gdd::copyStuff()",gddErrorNewFailed);
rc=gddErrorNewFailed;
}
break;
case 2: // Dup()
data=dd->getData(); // copy the data reference
@@ -404,14 +477,14 @@ size_t gdd::getDataSizeBytes(void) const
return sz;
}
size_t gdd::DescribedDataSizeBytes(void) const
size_t gdd::describedDataSizeBytes(void) const
{
size_t sz=0;
// does not work well for aitString - only reports the aitString info
if(!isContainer())
sz+=(size_t)(DescribedDataSizeElements())*aitSize[primitiveType()];
sz+=(size_t)(describedDataSizeElements())*aitSize[primitiveType()];
return sz;
}
@@ -471,14 +544,14 @@ aitUint32 gdd::getDataSizeElements(void) const
total=1;
else
{
if(voidData())
if(dataPointer())
for(i=0;i<dimension();i++) total+=bounds[i].size();
}
return total;
}
aitUint32 gdd::DescribedDataSizeElements(void) const
aitUint32 gdd::describedDataSizeElements(void) const
{
unsigned long total=0;
unsigned i;
@@ -544,8 +617,8 @@ size_t gdd::flattenWithAddress(void* buf, size_t size, aitIndex* total_dd)
{
if(data.FString)
memcpy((char*)&pdd[pos],data.FString,sizeof(aitFixedString));
else
pdd[0].data.FString=(aitFixedString*)&pdd[pos];
pdd[0].data.FString=(aitFixedString*)&pdd[pos];
}
else if(primitiveType()==aitEnumString)
{
@@ -554,6 +627,7 @@ size_t gdd::flattenWithAddress(void* buf, size_t size, aitIndex* total_dd)
{
memcpy((char*)&pdd[pos],str->string(),str->length()+1);
str->force((char*)&pdd[pos]);
str->forceConstant();
}
else
str->init();
@@ -562,7 +636,7 @@ size_t gdd::flattenWithAddress(void* buf, size_t size, aitIndex* total_dd)
else if(isContainer())
{
// need to check for bounds in the container and flatten them
if(voidData())
if(dataPointer())
{
// process all the container's DDs
spos=pos;
@@ -587,16 +661,16 @@ size_t gdd::flattenWithAddress(void* buf, size_t size, aitIndex* total_dd)
bnds=(gddBounds*)(&pdd[pos]);
for(i=0;i<dimension();i++) bnds[i]=bounds[i];
pdd[0].bounds=bnds;
if(voidData())
if(dataPointer())
{
if(primitiveType()==aitEnumString)
{
// not very good way to do it, size info bad
aitString::compact((aitString*)dataPointer(),
getDataSizeElements(),&bnds[i],size);
aitString* str = (aitString*)dataPointer();
aitString::compact(str,getDataSizeElements(),&bnds[i],size);
}
else
memcpy(&bnds[i],voidData(),getDataSizeBytes());
memcpy(&bnds[i],dataPointer(),getDataSizeBytes());
pdd[0].setData(&bnds[i]);
}
@@ -653,19 +727,20 @@ gddStatus gdd::flattenData(gdd* dd, int tot_dds, void* buf,size_t size)
ptr+=j*sizeof(gddBounds);
// copy the data
if(dd[i].voidData())
if(dd[i].dataPointer())
{
if(dd[i].primitiveType()==aitEnumString)
{
// not very good way to do it, size info bad
sz=aitString::compact((aitString*)dd[i].dataPointer(),
aitString* str = (aitString*)dd[i].dataPointer();
sz=aitString::compact(str,
dd[i].getDataSizeElements(),ptr,size);
}
else
{
// need to copy data here, align to size of double
sz=dd[i].getDataSizeBytes();
memcpy(ptr,dd[i].voidData(),sz);
memcpy(ptr,dd[i].dataPointer(),sz);
}
dd[i].setData(ptr);
ptr+=align8(sz); // do alignment
@@ -687,6 +762,7 @@ gddStatus gdd::flattenData(gdd* dd, int tot_dds, void* buf,size_t size)
{
memcpy(ptr,str->string(),str->length()+1);
str->force((char*)ptr);
str->forceConstant();
ptr+=str->length()+1;
}
else
@@ -728,7 +804,7 @@ int gdd::flattenDDs(gddContainer* dd, void* buf, size_t size)
{
if(ptr[i].isContainer())
{
if(ptr[i].voidData())
if(ptr[i].dataPointer())
{
spos=pos;
pos+=flattenDDs((gddContainer*)&ptr[i],&ptr[pos],
@@ -750,7 +826,7 @@ gddStatus gdd::convertOffsetsToAddress(void)
{
aitUint8* pdd = (aitUint8*)this;
aitUint32 bnds = (aitUint32)(bounds);
aitUint32 dp = (aitUint32)(voidData());
aitUint32 dp = (aitUint32)(dataPointer());
gdd* tdd;
gddContainer* cdd;
gddCursor cur;
@@ -818,7 +894,7 @@ gddStatus gdd::convertAddressToOffsets(void)
{
aitUint8* pdd = (aitUint8*)this;
aitUint8* bnds = (aitUint8*)(bounds);
aitUint8* dp = (aitUint8*)(voidData());
aitUint8* dp = (aitUint8*)(dataPointer());
gddContainer* tdd;
gddCursor cur;
gdd *cdd,*ddd;
@@ -828,7 +904,10 @@ gddStatus gdd::convertAddressToOffsets(void)
// does not ensure that all the members of a container are flat!
if(!isFlat())
{
gddAutoPrint("gdd::convertAddressToOffsets()",gddErrorNotAllowed);
return gddErrorNotAllowed;
}
if(isContainer())
{
@@ -883,16 +962,41 @@ gddStatus gdd::convertAddressToOffsets(void)
return 0;
}
gddStatus gdd::clearData(void)
{
gddStatus rc=0;
if(isContainer())
{
gddAutoPrint("gdd::clearData()",gddErrorNotAllowed);
rc=gddErrorNotAllowed;
}
else
{
if(destruct)
{
destruct->destroy(dataPointer());
destruct=NULL;
}
freeBounds();
setData(NULL);
}
return rc;
}
gddStatus gdd::clear(void)
{
if(isFlat()||isManaged())
{
gddAutoPrint("gdd::clear()",gddErrorNotAllowed);
return gddErrorNotAllowed;
}
if(isAtomic())
{
if(destruct)
{
destruct->destroy(voidData());
destruct->destroy(dataPointer());
destruct=NULL;
}
freeBounds();
@@ -932,7 +1036,10 @@ gddStatus gdd::reset(aitEnum prim, int dimen, aitIndex* cnt)
gddStatus rc;
if(isFlat()||isManaged()||isContainer())
{
gddAutoPrint("gdd::reset()",gddErrorNotAllowed);
return gddErrorNotAllowed;
}
app=applicationType();
@@ -959,12 +1066,12 @@ void gdd::get(aitString& d)
if(isConstant())
{
const char* ci=(const char*)dataPointer();
d.copy(ci);
d.installString(ci);
}
else
{
char* i=(char*)dataPointer();
d.copy(i);
d.installString(i);
}
}
else
@@ -987,12 +1094,12 @@ void gdd::getConvert(aitString& d)
if(isConstant())
{
const char* ci=(const char*)dataPointer();
d.copy(ci);
d.installString(ci);
}
else
{
char* i=(char*)dataPointer();
d.copy(i);
d.installString(i);
}
}
else
@@ -1007,21 +1114,64 @@ void gdd::getConvert(aitFixedString& d)
get(aitEnumFixedString,d.fixed_string);
}
void gdd::put(aitString d)
gddStatus gdd::put(const aitString& d)
{
aitString* s=(aitString*)dataAddress();
*s=d;
setPrimType(aitEnumString);
gddStatus rc=0;
if(isScalar())
{
aitString* s=(aitString*)dataAddress();
*s=d;
setPrimType(aitEnumString);
}
else
{
gddAutoPrint("gdd::put(aitString&)",gddErrorNotAllowed);
rc=gddErrorNotAllowed;
}
return rc;
}
gddStatus gdd::put(aitString& d)
{
gddStatus rc=0;
if(isScalar())
{
aitString* s=(aitString*)dataAddress();
*s=d;
setPrimType(aitEnumString);
}
else
{
gddAutoPrint("gdd::put(aitString&)",gddErrorNotAllowed);
rc=gddErrorNotAllowed;
}
return rc;
}
// this is dangerous, should the fixed string be copied here?
void gdd::put(aitFixedString& d)
gddStatus gdd::put(const aitFixedString& d)
{
data.FString=&d;
setPrimType(aitEnumFixedString);
gddStatus rc=0;
if(primitiveType()==aitEnumFixedString)
{
if(data.FString==NULL)
data.FString=new aitFixedString;
}
else
{
// this is so bad, like the other put() functions, need fixen
setPrimType(aitEnumFixedString);
data.FString=new aitFixedString;
}
memcpy(data.FString->fixed_string,d.fixed_string,sizeof(d.fixed_string));
return rc;
}
void gdd::putConvert(aitString d)
void gdd::putConvert(const aitString& d)
{
if(primitiveType()==aitEnumInt8 && dim==1)
{
@@ -1032,10 +1182,10 @@ void gdd::putConvert(aitString d)
cp[len]='\0';
}
else
set(aitEnumString,&d);
set(aitEnumString,(aitString*)&d);
}
void gdd::putConvert(aitFixedString& d)
void gdd::putConvert(const aitFixedString& d)
{
if(primitiveType()==aitEnumInt8 && dim==1)
{
@@ -1046,20 +1196,13 @@ void gdd::putConvert(aitFixedString& d)
cp[len]='\0';
}
else
set(aitEnumFixedString,d.fixed_string);
set(aitEnumFixedString,(void*)d.fixed_string);
}
// copy each of the strings into this DDs storage area
gddStatus gdd::put(const aitString* const d)
{
gddStatus rc=0;
if(isAtomic())
aitConvert(primitiveType(),voidData(),aitEnumString,d,getDataSizeElements());
else
rc=gddErrorTypeMismatch;
return rc;
return genCopy(aitEnumString,d);
}
// copy each of the strings into this DDs storage area
@@ -1068,14 +1211,16 @@ gddStatus gdd::put(const aitFixedString* const d)
gddStatus rc=0;
if(isAtomic())
if(data.FString)
{
aitConvert(primitiveType(),voidData(),aitEnumFixedString,d,
if(dataPointer())
aitConvert(primitiveType(),dataPointer(),aitEnumFixedString,d,
getDataSizeElements());
}
// should have else error condition
else
genCopy(aitEnumFixedString,d);
else
{
gddAutoPrint("gdd::put(const aitFixedString*const)",gddErrorNotAllowed);
rc=gddErrorTypeMismatch;
}
return rc;
}
@@ -1084,25 +1229,122 @@ gddStatus gdd::put(const gdd* dd)
{
gddStatus rc=0;
// bail out quickly is either dd is a container
if(isContainer() || dd->isContainer())
rc=gddErrorNotSupported;
else if(isScalar() && dd->isScalar())
{
gddAutoPrint("gdd::put(const gdd*)",gddErrorNotSupported);
return gddErrorNotSupported;
}
if(!aitConvertValid(primitiveType()))
{
// can't change application type here
int app = applicationType();
init(app,dd->primitiveType(),dd->dimension());
}
if(isScalar() && dd->isScalar())
{
// this is the simple case - just make this scaler look like the other
// not protected against screwing up the string type
setPrimType(dd->primitiveType());
put(((aitType*)dd->dataAddress()));
// set(dd->primitiveType(),dd->dataAddress());
// need to make sure that aitString and aitFixedString work right
if(primitiveType()==aitEnumFixedString && data.FString==NULL)
data.FString=new aitFixedString;
if(dd->primitiveType()==aitEnumFixedString)
set(dd->primitiveType(),dd->dataPointer());
else
set(dd->primitiveType(),dd->dataAddress());
}
else if(isAtomic() && dd->isAtomic())
else if(isScalar()) // dd must be atomic if this is true
{
if((primitiveType()==aitEnumString ||
primitiveType()==aitEnumFixedString) &&
dd->primitiveType()==aitEnumInt8)
{
// special case for aitInt8--->aitString (hate this)
aitInt8* i1=(aitInt8*)dd->dataPointer();
put(i1);
}
else
{
if(primitiveType()==aitEnumFixedString && data.FString==NULL)
data.FString=new aitFixedString;
set(dd->primitiveType(),dd->dataPointer());
}
}
else if(dd->isScalar()) // this must be atomic if true
{
if(primitiveType()==aitEnumInt8 &&
dd->primitiveType()==aitEnumString)
{
// special case for aitString--->aitInt8
aitString* s1=(aitString*)dd->dataAddress();
put(*s1);
}
else if(primitiveType()==aitEnumInt8 &&
dd->primitiveType()==aitEnumFixedString)
{
// special case for aitFixedString--->aitInt8
aitFixedString* s2=data.FString;
if(s2) put(*s2);
}
else
{
if(getDataSizeElements()>0)
{
aitConvert(primitiveType(),dataPointer(),
dd->primitiveType(),dd->dataAddress(),1);
}
else
{
// this may expose an inconsistancy in the library.
// you can register a gdd with bounds and no data
// which marks it flat
if(isFlat())
{
gddAutoPrint("gdd::put(const gdd*)",gddErrorNotAllowed);
rc=gddErrorNotAllowed;
}
else
{
// convert it to a scalar - is this OK to do?
clearData();
setPrimType(dd->primitiveType());
setApplType(applicationType());
setDimension(0);
put((aitType*)dd->dataAddress());
}
}
}
}
else // both dd and this must be atomic
{
// carefully place values from dd into this
if(dd->getDataSizeElements()>getDataSizeElements())
if(dataPointer()==NULL)
{
if(destruct)
{
gddAutoPrint("gdd::put(const gdd*)",gddErrorNotAllowed);
rc=gddErrorNotAllowed;
}
else
rc=copyData(dd); // is this the correct thing to do?
}
else if(dd->getDataSizeElements()>getDataSizeElements())
{
gddAutoPrint("gdd::put(const gdd*)",gddErrorOutOfBounds);
rc=gddErrorOutOfBounds;
}
else
{
if(dd->dimension()>1)
return gddErrorNotSupported;
{
gddAutoPrint("gdd::put(const gdd*)",gddErrorNotSupported);
rc=gddErrorNotSupported;
}
else
{
aitUint8* arr = (aitUint8*)dataPointer();
@@ -1113,90 +1355,9 @@ gddStatus gdd::put(const gdd* dd)
dd->dataPointer(),
dd->getBounds()->size());
}
#if 0
// should handle single dimensional array as a special case
const Bounds* b = dd->getBounds();
const Bounds* bs = getBounds();
aitIndex x[dd->dimension()];
aitIndex offset,mult;
aitUint8* arr_dest=(aitUint8*)dataPointer();
aitUint8* arr_src=(aitUint8*)dd->dataPointer();
int d = dd->dimension();
int i,j;
for(i=0;i<d;i++) x[i]=b[i].first();
// look at this ugly mess - slow and horrible, but generic
// this is so unbelievably sucky, I hate it
j=0;
while(x[d-1]<b[d-1].size())
{
// modify coordinate here
for(offset=x[0],mult=1,i=1;i<d;i++)
{
mult*=bs[i];
offset+=x[i]*mult;
}
aitConvert(primitiveType(),
arr_dest[offset*aitSize[dd->primitiveType()],
dd->primitiveType(),arr_src[j],1);
if(++x[0]>=b[0].size())
{
for(i=0;i<(d-1);i++)
{
if(x[i]>=b[i].size())
{
++x[i+1];
x[i]=b[i].first();
}
}
}
j++;
}
#endif
}
}
else if((primitiveType()==aitEnumString ||
primitiveType()==aitEnumFixedString) &&
dd->primitiveType()==aitEnumInt8 &&
isScalar() && dd->isAtomic())
{
// special case for aitInt8--->aitString (hate this)
aitInt8* i1=(aitInt8*)dd->dataPointer();
put(i1);
}
else if(primitiveType()==aitEnumInt8 &&
dd->primitiveType()==aitEnumString &&
dd->isScalar() && isAtomic())
{
// special case for aitString--->aitInt8
aitString* s1=(aitString*)dd->dataAddress();
put(*s1);
}
else if(primitiveType()==aitEnumInt8 &&
dd->primitiveType()==aitEnumFixedString &&
dd->isScalar() && isAtomic())
{
// special case for aitFixedString--->aitInt8
aitFixedString* s2=data.FString;
if(s2) put(*s2);
}
else if(isScalar())
{
// just put first element of dd into this scaler - sucks
if(dd->getDataSizeElements()>0)
aitConvert(primitiveType(),dataAddress(),
dd->primitiveType(),dd->dataPointer(),1);
}
else
{
// just put dd scaler into first element of this - sucks
if(getDataSizeElements()>0)
aitConvert(primitiveType(),dataPointer(),
dd->primitiveType(),dd->dataAddress(),1);
}
aitTimeStamp ts;
setStatSevr(dd->getStat(),dd->getSevr());
@@ -1206,6 +1367,42 @@ gddStatus gdd::put(const gdd* dd)
return rc;
}
gddStatus gdd::copyData(const gdd* dd)
{
gddStatus rc=0;
if(isFlat() || isManaged() || isContainer())
{
gddAutoPrint("gdd::copyData(const gdd*)",gddErrorNotAllowed);
rc=gddErrorNotAllowed;
}
else
{
if((rc=clear())==0)
{
int i;
init(dd->applicationType(),dd->primitiveType(),dd->dimension());
const gddBounds* bnds = dd->getBounds();
for(i=0;i<dd->dimension();i++) bounds[i]=bnds[i];
size_t sz = dd->getDataSizeBytes();
aitUint8* arr;
if((arr=new aitUint8[sz]))
{
destruct=new gddDestructor;
memcpy(arr,dd->dataPointer(),sz);
setData(arr);
}
else
{
gddAutoPrint("gdd::copyData(const gdd*)",gddErrorNewFailed);
rc=gddErrorNewFailed;
}
}
}
return rc;
}
// ----------------------The gddAtomic functions-------------------------
gddAtomic::gddAtomic(int app, aitEnum prim, int dimen, ...):
@@ -1232,7 +1429,10 @@ gddStatus gddAtomic::getBoundingBoxSize(aitUint32* b)
if(dimension()>0)
for(i=0;i<dimension();i++) b[i]=bounds[i].size();
else
{
gddAutoPrint("gddAtomic::getBoundingBoxSize()",gddErrorOutOfBounds);
rc=gddErrorOutOfBounds;
}
return rc;
}
@@ -1245,7 +1445,10 @@ gddStatus gddAtomic::setBoundingBoxSize(const aitUint32* const b)
if(dimension()>0)
for(i=0;i<dimension();i++) bounds[i].setSize(b[i]);
else
{
gddAutoPrint("gddAtomic::setBoundingBoxSize()",gddErrorOutOfBounds);
rc=gddErrorOutOfBounds;
}
return rc;
}
@@ -1258,7 +1461,10 @@ gddStatus gddAtomic::getBoundingBoxOrigin(aitUint32* b)
if(dimension()>0)
for(i=0;i<dimension();i++) b[i]=bounds[i].first();
else
{
gddAutoPrint("gddAtomic::getBoundingBoxOrigin()",gddErrorOutOfBounds);
rc=gddErrorOutOfBounds;
}
return rc;
}
@@ -1271,7 +1477,10 @@ gddStatus gddAtomic::setBoundingBoxOrigin(const aitUint32* const b)
if(dimension()>0)
for(i=0;i<dimension();i++) bounds[i].setSize(b[i]);
else
{
gddAutoPrint("gddAtomic::setBoundingBoxOrigin",gddErrorOutOfBounds);
rc=gddErrorOutOfBounds;
}
return rc;
}
@@ -1336,7 +1545,7 @@ gddContainer::gddContainer(gddContainer* ec)
gdd* gddContainer::getDD(aitIndex index)
{
aitIndex i;
gdd* dd=(gdd*)voidData();
gdd* dd=(gdd*)dataPointer();
for(i=0;i<index && i<bounds->size();i++) dd=(gdd*)dd->next();
return dd;
}
@@ -1371,7 +1580,10 @@ gddStatus gddContainer::remove(aitIndex index)
return 0;
}
else
{
gddAutoPrint("gddContainer::remove()",gddErrorOutOfBounds);
return gddErrorOutOfBounds;
}
}
// ------------------------cursor functions-------------------------------
@@ -1398,3 +1610,49 @@ gdd* gddCursor::operator[](int index)
return dd;
}
#if 0
code section for handling transfer of element from
multidimensional space
// should handle single dimensional array as a special case
const Bounds* b = dd->getBounds();
const Bounds* bs = getBounds();
aitIndex x[dd->dimension()];
aitIndex offset,mult;
aitUint8* arr_dest=(aitUint8*)dataPointer();
aitUint8* arr_src=(aitUint8*)dd->dataPointer();
int d = dd->dimension();
int i,j;
for(i=0;i<d;i++) x[i]=b[i].first();
// look at this ugly mess - slow and horrible, but generic
// this is so unbelievably sucky, I hate it
j=0;
while(x[d-1]<b[d-1].size())
{
// modify coordinate here
for(offset=x[0],mult=1,i=1;i<d;i++)
{
mult*=bs[i];
offset+=x[i]*mult;
}
aitConvert(primitiveType(),
arr_dest[offset*aitSize[dd->primitiveType()],
dd->primitiveType(),arr_src[j],1);
if(++x[0]>=b[0].size())
{
for(i=0;i<(d-1);i++)
{
if(x[i]>=b[i].size())
{
++x[i+1];
x[i]=b[i].first();
}
}
}
j++;
}
#endif

View File

@@ -8,6 +8,15 @@
* $Id$
*
* $Log$
* Revision 1.12 1996/08/27 13:05:06 jbk
* final repairs to string functions, put() functions, and error code printing
*
* Revision 1.11 1996/08/22 21:05:41 jbk
* More fixes to make strings and fixed string work better.
*
* Revision 1.10 1996/08/14 16:29:38 jbk
* fixed a put() function that did not return anything
*
* Revision 1.9 1996/08/14 12:30:15 jbk
* fixes for converting aitString to aitInt8* and back
* fixes for managing the units field for the dbr types
@@ -61,12 +70,17 @@
#include <string.h>
#include <limits.h>
#include <sys/types.h>
#ifndef vxWorks
#include <stdlib.h>
#include <unistd.h>
#include <sys/time.h>
#else
#include <time.h>
#if defined(WIN32)
# include <stdlib.h>
#elif defined(vxWorks)
# include <time.h>
# include <timers.h> // for timespec under v51 vxWorks
#elif defined(UNIX)
// hopefully a posix compliant OS
# include <stdlib.h>
# include <unistd.h>
# include <sys/time.h>
#endif
// strdup is not defined under POSIX
@@ -311,9 +325,11 @@ public:
void setPrimType(aitEnum t);
void setApplType(int t);
void setDimension(int d);
void destroyData(void);
gddStatus reset(aitEnum primtype,int dimension, aitIndex* dim_counts);
gddStatus clear(void); // clear all fields of the DD, including arrays
gddStatus clearData(void);
gddStatus changeType(int appltype, aitEnum primtype);
gddStatus setBound(unsigned dim_to_set, aitIndex first, aitIndex count);
gddStatus getBound(unsigned dim_to_get, aitIndex& first, aitIndex& count);
@@ -353,6 +369,7 @@ public:
// copy data into it.
// Dup() will copy DD info. bounds, data references copied only.
gddStatus copyData(const gdd*);
gddStatus copyInfo(gdd*);
gddStatus copy(gdd*);
gddStatus Dup(gdd*);
@@ -446,8 +463,8 @@ public:
void putConvert(aitInt16 d);
void putConvert(aitUint8 d);
void putConvert(aitInt8 d);
void putConvert(aitString d);
void putConvert(aitFixedString& d);
void putConvert(const aitString& d);
void putConvert(const aitFixedString& d);
// copy the user data into the already set up DD array
gddStatus put(const aitFloat64* const d);
@@ -463,17 +480,18 @@ public:
gddStatus put(const gdd* dd);
// put the user data into the DD and reset the primitive type
void put(aitFloat64 d);
void put(aitFloat32 d);
void put(aitUint32 d);
void put(aitInt32 d);
void put(aitUint16 d);
void put(aitInt16 d);
void put(aitUint8 d);
void put(aitInt8 d);
void put(aitString d);
void put(aitFixedString& d);
void put(aitType* d);
gddStatus put(aitFloat64 d);
gddStatus put(aitFloat32 d);
gddStatus put(aitUint32 d);
gddStatus put(aitInt32 d);
gddStatus put(aitUint16 d);
gddStatus put(aitInt16 d);
gddStatus put(aitUint8 d);
gddStatus put(aitInt8 d);
gddStatus put(aitString& d);
gddStatus put(const aitString& d);
gddStatus put(const aitFixedString& d);
gddStatus put(aitType* d);
// copy the array data out of the DD
void get(void* d);
@@ -523,7 +541,8 @@ public:
gdd& operator=(aitInt16 d);
gdd& operator=(aitUint8 d);
gdd& operator=(aitInt8 d);
gdd& operator=(aitString d);
gdd& operator=(aitString& d);
gdd& operator=(const aitString& d);
// gdd& operator=(aitFixedString d); // not present
// Same as getRef() methods
@@ -565,15 +584,14 @@ protected:
void dumpInfo(void);
gddStatus copyStuff(gdd*,int type);
size_t DescribedDataSizeBytes(void) const;
aitUint32 DescribedDataSizeElements(void) const;
size_t describedDataSizeBytes(void) const;
aitUint32 describedDataSizeElements(void) const;
void markFlat(void);
gddStatus flattenData(gdd* dd, int tot_dds, void* buf, size_t size);
int flattenDDs(gddContainer* dd, void* buf, size_t size);
aitUint32 align8(unsigned long count) const;
void* voidData(void) const;
void setData(void* d);
aitType data; // array pointer or scaler data
@@ -590,7 +608,6 @@ private:
aitUint8 flags;
};
inline void* gdd::voidData(void) const { return data.Pointer; }
inline void gdd::setData(void* d) { data.Pointer=d; }
inline gddDestructor* gdd::destructor(void) const { return destruct; }
@@ -612,7 +629,7 @@ inline gddStatus gdd::copyInfo(gdd* dd) { return copyStuff(dd,0); }
inline gddStatus gdd::copy(gdd* dd) { return copyStuff(dd,1); }
inline gddStatus gdd::Dup(gdd* dd) { return copyStuff(dd,2); }
inline void* gdd::dataAddress(void) const { return (void*)&data; }
inline void* gdd::dataPointer(void) const { return voidData(); }
inline void* gdd::dataPointer(void) const { return data.Pointer; }
inline aitUint32 gdd::align8(unsigned long count) const
{
@@ -621,7 +638,7 @@ inline aitUint32 gdd::align8(unsigned long count) const
}
inline void* gdd::dataPointer(aitIndex f) const
{ return (void*)(((aitUint8*)voidData())+aitSize[primitiveType()]*f); }
{ return (void*)(((aitUint8*)dataPointer())+aitSize[primitiveType()]*f); }
inline int gdd::isManaged(void) const { return flags&GDD_MANAGED_MASK; }
inline int gdd::isFlat(void) const { return flags&GDD_FLAT_MASK; }
@@ -673,7 +690,11 @@ inline int gdd::isAtomic(void) const
inline gddStatus gdd::noReferencing(void)
{
int rc=0;
if(ref_cnt>1) rc=gddErrorNotAllowed;
if(ref_cnt>1)
{
gddAutoPrint("gdd::noReferencing()",gddErrorNotAllowed);
rc=gddErrorNotAllowed;
}
else flags|=GDD_NOREF_MASK;
return rc;
}
@@ -681,12 +702,17 @@ inline gddStatus gdd::reference(void)
{
int rc=0;
if(isNoRef()) rc=gddErrorNotAllowed;
if(isNoRef())
{
gddAutoPrint("gdd::reference()",gddErrorNotAllowed);
rc=gddErrorNotAllowed;
}
else ref_cnt++;
if(ref_cnt>((1u<<(sizeof(ref_cnt)*CHAR_BIT))-2u))
{
fprintf(stderr,"gdd reference count overflow!!\n");
gddAutoPrint("gdd::reference()",gddErrorOverflow);
rc=gddErrorOverflow;
}
return rc;
@@ -699,6 +725,7 @@ inline gddStatus gdd::unreference(void)
if(ref_cnt==0u)
{
fprintf(stderr,"gdd reference count underflow!!\n");
gddAutoPrint("gdd::unreference()",gddErrorUnderflow);
rc=gddErrorUnderflow;
}
else if(--ref_cnt<=0u)
@@ -708,6 +735,7 @@ inline gddStatus gdd::unreference(void)
// managed dd always destroys the entire thing
ref_cnt=1;
if(destruct) destruct->run(this);
destruct=NULL;
}
else if(!isFlat())
delete this;
@@ -723,7 +751,7 @@ inline void gdd::destroyData(void)
if(isContainer())
destruct->run(this);
else
destruct->run(voidData());
destruct->run(dataPointer());
}
else
{
@@ -737,32 +765,56 @@ inline void gdd::destroyData(void)
inline void gdd::adjust(gddDestructor* d, void* v, aitEnum type)
{
if(destruct) destruct->destroy(voidData());
if(destruct) destruct->destroy(dataPointer());
destruct=d;
if(destruct) destruct->reference();
setPrimType(type);
setData(v);
}
// These function do NOT work well for aitFixedString because
// fixed strings are always stored by reference. You WILL get
// into trouble is the gdd does not contain a fixed string
// before you putConvert() something into it.
inline void gdd::get(aitEnum t,void* v)
{ aitConvert(t,v,primitiveType(),&data,1); }
{
if(primitiveType()==aitEnumFixedString)
{
if(dataPointer()) aitConvert(t,v,primitiveType(),dataPointer(),1);
}
else
aitConvert(t,v,primitiveType(),dataAddress(),1);
}
inline void gdd::set(aitEnum t,void* v)
{ aitConvert(primitiveType(),&data,t,v,1); }
{
if(primitiveType()==aitEnumFixedString)
{
if(dataPointer()==NULL) data.FString=new aitFixedString;
aitConvert(primitiveType(),dataPointer(),t,v,1);
}
else
aitConvert(primitiveType(),dataAddress(),t,v,1);
}
inline void gdd::getRef(aitFloat64*& d) { d=(aitFloat64*)voidData(); }
inline void gdd::getRef(aitFloat32*& d) { d=(aitFloat32*)voidData(); }
inline void gdd::getRef(aitUint32*& d) { d=(aitUint32*)voidData(); }
inline void gdd::getRef(aitInt32*& d) { d=(aitInt32*)voidData(); }
inline void gdd::getRef(aitUint16*& d) { d=(aitUint16*)voidData(); }
inline void gdd::getRef(aitInt16*& d) { d=(aitInt16*)voidData(); }
inline void gdd::getRef(aitUint8*& d) { d=(aitUint8*)voidData(); }
inline void gdd::getRef(aitInt8*& d) { d=(aitInt8*)voidData(); }
inline void gdd::getRef(void*& d) { d=voidData(); }
inline void gdd::getRef(aitFixedString*& d) { d=(aitFixedString*)voidData(); }
inline void gdd::getRef(aitString*& d)
{ if(isScalar()) d=(aitString*)dataAddress(); else d=(aitString*)voidData(); }
// -------------------getRef(data pointer) functions----------------
inline void gdd::getRef(aitFloat64*& d) { d=(aitFloat64*)dataPointer(); }
inline void gdd::getRef(aitFloat32*& d) { d=(aitFloat32*)dataPointer(); }
inline void gdd::getRef(aitUint32*& d) { d=(aitUint32*)dataPointer(); }
inline void gdd::getRef(aitInt32*& d) { d=(aitInt32*)dataPointer(); }
inline void gdd::getRef(aitUint16*& d) { d=(aitUint16*)dataPointer(); }
inline void gdd::getRef(aitInt16*& d) { d=(aitInt16*)dataPointer(); }
inline void gdd::getRef(aitUint8*& d) { d=(aitUint8*)dataPointer(); }
inline void gdd::getRef(aitInt8*& d) { d=(aitInt8*)dataPointer(); }
inline void gdd::getRef(void*& d) { d=dataPointer(); }
inline void gdd::getRef(aitFixedString*& d) {d=(aitFixedString*)dataPointer();}
inline void gdd::getRef(aitString*& d) {
if(isScalar()) d=(aitString*)dataAddress();
else d=(aitString*)dataPointer();
}
// -------------------putRef(data pointer) functions----------------
inline void gdd::putRef(void* v,aitEnum code, gddDestructor* d)
{ adjust(d, v, code); }
inline void gdd::putRef(aitFloat64* v, gddDestructor* d)
@@ -786,6 +838,7 @@ inline void gdd::putRef(aitString* v, gddDestructor* d)
inline void gdd::putRef(aitFixedString* v, gddDestructor* d)
{ adjust(d, (void*)v, aitEnumFixedString); }
// -------------------putRef(const data pointer) functions----------------
inline void gdd::putRef(const aitFloat64* v, gddDestructor* d)
{ adjust(d, (void*)v, aitEnumFloat64); markConstant(); }
inline void gdd::putRef(const aitFloat32* v, gddDestructor* d)
@@ -807,6 +860,7 @@ inline void gdd::putRef(const aitString* v, gddDestructor* d)
inline void gdd::putRef(const aitFixedString* v, gddDestructor* d)
{ adjust(d, (void*)v, aitEnumFixedString); markConstant(); }
// -------------------getConvert(scalar) functions ----------------------
inline void gdd::getConvert(aitFloat64& d) { get(aitEnumFloat64,&d); }
inline void gdd::getConvert(aitFloat32& d) { get(aitEnumFloat32,&d); }
inline void gdd::getConvert(aitUint32& d) { get(aitEnumUint32,&d); }
@@ -816,6 +870,7 @@ inline void gdd::getConvert(aitInt16& d) { get(aitEnumInt16,&d); }
inline void gdd::getConvert(aitUint8& d) { get(aitEnumUint8,&d); }
inline void gdd::getConvert(aitInt8& d) { get(aitEnumInt8,&d); }
// -------------------putConvert(scalar) functions ----------------------
inline void gdd::putConvert(aitFloat64 d){ set(aitEnumFloat64,&d); }
inline void gdd::putConvert(aitFloat32 d){ set(aitEnumFloat32,&d); }
inline void gdd::putConvert(aitUint32 d) { set(aitEnumUint32,&d); }
@@ -825,6 +880,7 @@ inline void gdd::putConvert(aitInt16 d) { set(aitEnumInt16,&d); }
inline void gdd::putConvert(aitUint8 d) { set(aitEnumUint8,&d); }
inline void gdd::putConvert(aitInt8 d) { set(aitEnumInt8,&d); }
// ------------------------put(pointer) functions----------------------
inline gddStatus gdd::put(const aitFloat64* const d)
{ return genCopy(aitEnumFloat64,d); }
inline gddStatus gdd::put(const aitFloat32* const d)
@@ -848,10 +904,7 @@ inline gddStatus gdd::put(const aitInt8* const d)
if(primitiveType()==aitEnumString && dim==0)
{
aitString* p = (aitString*)dataAddress();
if(isConstant())
p->replaceData((char*)d);
else
p->copy((char*)d);
p->installString((char*)d);
}
else if(primitiveType()==aitEnumFixedString && dim==0)
strcpy(data.FString->fixed_string,(char*)d);
@@ -861,39 +914,108 @@ inline gddStatus gdd::put(const aitInt8* const d)
return rc;
}
// currently unprotected from destroying an atomic gdd
inline void gdd::put(aitFloat64 d){ data.Float64=d;setPrimType(aitEnumFloat64);}
inline void gdd::put(aitFloat32 d){ data.Float32=d;setPrimType(aitEnumFloat32);}
inline void gdd::put(aitUint32 d) { data.Uint32=d; setPrimType(aitEnumUint32); }
inline void gdd::put(aitInt32 d) { data.Int32=d; setPrimType(aitEnumInt32); }
inline void gdd::put(aitUint16 d) { data.Uint16=d; setPrimType(aitEnumUint16); }
inline void gdd::put(aitInt16 d) { data.Int16=d; setPrimType(aitEnumInt16); }
inline void gdd::put(aitUint8 d) { data.Uint8=d; setPrimType(aitEnumUint8); }
inline void gdd::put(aitInt8 d) { data.Int8=d; setPrimType(aitEnumInt8); }
inline void gdd::put(aitType* d) { data=*d; }
// ----------------put(scalar) functions----------------
inline gddStatus gdd::put(aitFloat64 d) {
gddStatus rc=0;
if(isScalar()) { data.Float64=d; setPrimType(aitEnumFloat64); }
else { rc=gddErrorNotAllowed; gddAutoPrint("gdd:put()",rc); }
return rc;
}
inline gddStatus gdd::put(aitFloat32 d) {
gddStatus rc=0;
if(isScalar()) { data.Float32=d;setPrimType(aitEnumFloat32); }
else { rc=gddErrorNotAllowed; gddAutoPrint("gdd:put()",rc); }
return rc;
}
inline gddStatus gdd::put(aitUint32 d) {
gddStatus rc=0;
if(isScalar()) { data.Uint32=d; setPrimType(aitEnumUint32); }
else { rc=gddErrorNotAllowed; gddAutoPrint("gdd:put()",rc); }
return rc;
}
inline gddStatus gdd::put(aitInt32 d) {
gddStatus rc=0;
if(isScalar()) { data.Int32=d; setPrimType(aitEnumInt32); }
else { rc=gddErrorNotAllowed; gddAutoPrint("gdd:put()",rc); }
return rc;
}
inline gddStatus gdd::put(aitUint16 d) {
gddStatus rc=0;
if(isScalar()) { data.Uint16=d; setPrimType(aitEnumUint16); }
else { rc=gddErrorNotAllowed; gddAutoPrint("gdd:put()",rc); }
return rc;
}
inline gddStatus gdd::put(aitInt16 d) {
gddStatus rc=0;
if(isScalar()) { data.Int16=d; setPrimType(aitEnumInt16); }
else { rc=gddErrorNotAllowed; gddAutoPrint("gdd:put()",rc); }
return rc;
}
inline gddStatus gdd::put(aitUint8 d) {
gddStatus rc=0;
if(isScalar()) { data.Uint8=d; setPrimType(aitEnumUint8); }
else { rc=gddErrorNotAllowed; gddAutoPrint("gdd:put()",rc); }
return rc;
}
inline gddStatus gdd::put(aitInt8 d) {
gddStatus rc=0;
if(isScalar()) { data.Int8=d; setPrimType(aitEnumInt8); }
else { rc=gddErrorNotAllowed; gddAutoPrint("gdd:put()",rc); }
return rc;
}
inline gddStatus gdd::put(aitType* d) {
gddStatus rc=0;
if(isScalar()) { data=*d; }
else { rc=gddErrorNotAllowed; gddAutoPrint("gdd:put()",rc); }
return rc;
}
inline void gdd::get(void* d)
{ aitConvert(primitiveType(),d,primitiveType(),voidData(),getDataSizeElements());}
inline void gdd::get(void* d,aitEnum e)
{ aitConvert(e,d,primitiveType(),voidData(),getDataSizeElements()); }
// ---------------------get(pointer) functions--------------------------
inline void gdd::get(void* d) {
aitConvert(primitiveType(),d,primitiveType(),dataPointer(),
getDataSizeElements());
}
inline void gdd::get(void* d,aitEnum e) {
aitConvert(e,d,primitiveType(),dataPointer(),
getDataSizeElements());
}
inline void gdd::get(aitFloat64* d)
{ aitConvert(aitEnumFloat64,d,primitiveType(),voidData(),getDataSizeElements()); }
inline void gdd::get(aitFloat32* d)
{ aitConvert(aitEnumFloat32,d,primitiveType(),voidData(),getDataSizeElements()); }
inline void gdd::get(aitUint32* d)
{ aitConvert(aitEnumUint32,d,primitiveType(),voidData(),getDataSizeElements()); }
inline void gdd::get(aitInt32* d)
{ aitConvert(aitEnumInt32,d,primitiveType(),voidData(),getDataSizeElements()); }
inline void gdd::get(aitUint16* d)
{ aitConvert(aitEnumUint16,d,primitiveType(),voidData(),getDataSizeElements()); }
inline void gdd::get(aitInt16* d)
{ aitConvert(aitEnumInt16,d,primitiveType(),voidData(),getDataSizeElements()); }
inline void gdd::get(aitUint8* d)
{ aitConvert(aitEnumUint8,d,primitiveType(),voidData(),getDataSizeElements()); }
inline void gdd::get(aitString* d)
{ aitConvert(aitEnumString,d,primitiveType(),voidData(),getDataSizeElements()); }
inline void gdd::get(aitFixedString* d)
{ aitConvert(aitEnumFixedString,d,primitiveType(),voidData(),getDataSizeElements()); }
{
aitConvert(aitEnumFloat64,d,primitiveType(),dataPointer(),
getDataSizeElements());
}
inline void gdd::get(aitFloat32* d) {
aitConvert(aitEnumFloat32,d,primitiveType(),dataPointer(),
getDataSizeElements());
}
inline void gdd::get(aitUint32* d) {
aitConvert(aitEnumUint32,d,primitiveType(),dataPointer(),
getDataSizeElements());
}
inline void gdd::get(aitInt32* d) {
aitConvert(aitEnumInt32,d,primitiveType(),dataPointer(),
getDataSizeElements());
}
inline void gdd::get(aitUint16* d) {
aitConvert(aitEnumUint16,d,primitiveType(),dataPointer(),
getDataSizeElements());
}
inline void gdd::get(aitInt16* d) {
aitConvert(aitEnumInt16,d,primitiveType(),dataPointer(),
getDataSizeElements());
}
inline void gdd::get(aitUint8* d) {
aitConvert(aitEnumUint8,d,primitiveType(),dataPointer(),
getDataSizeElements());
}
inline void gdd::get(aitString* d) {
aitConvert(aitEnumString,d,primitiveType(),dataPointer(),
getDataSizeElements());
}
inline void gdd::get(aitFixedString* d) {
aitConvert(aitEnumFixedString,d,primitiveType(),dataPointer(),
getDataSizeElements());
}
// special case for string scalar to aitInt8 array!
inline void gdd::get(aitInt8* d)
@@ -906,9 +1028,11 @@ inline void gdd::get(aitInt8* d)
else if(primitiveType()==aitEnumFixedString && dim==0)
strcpy((char*)d,data.FString->fixed_string);
else
aitConvert(aitEnumInt8,d,primitiveType(),voidData(),getDataSizeElements());
aitConvert(aitEnumInt8,d,primitiveType(),dataPointer(),
getDataSizeElements());
}
// ------------------get(scalar) functions-----------------
inline void gdd::get(aitFloat64& d) {
if(primitiveType()==aitEnumFloat64) d=getData().Float64;
else get(aitEnumFloat64,&d);
@@ -943,6 +1067,7 @@ inline void gdd::get(aitInt8& d) {
}
inline void gdd::get(aitType& d) { d=data; }
// ---------- gdd x = primitive data type pointer functions----------
inline gdd& gdd::operator=(aitFloat64* v) { putRef(v); return *this;}
inline gdd& gdd::operator=(aitFloat32* v) { putRef(v); return *this;}
inline gdd& gdd::operator=(aitUint32* v) { putRef(v); return *this;}
@@ -954,28 +1079,51 @@ inline gdd& gdd::operator=(aitInt8* v) { putRef(v); return *this;}
inline gdd& gdd::operator=(aitString* v) { putRef(v); return *this;}
inline gdd& gdd::operator=(aitFixedString* v){ putRef(v); return *this;}
inline gdd& gdd::operator=(aitFloat64 d) { put(d); return *this; }
inline gdd& gdd::operator=(aitFloat32 d) { put(d); return *this; }
inline gdd& gdd::operator=(aitUint32 d) { put(d); return *this; }
inline gdd& gdd::operator=(aitInt32 d) { put(d); return *this; }
inline gdd& gdd::operator=(aitUint16 d) { put(d); return *this; }
inline gdd& gdd::operator=(aitInt16 d) { put(d); return *this; }
inline gdd& gdd::operator=(aitUint8 d) { put(d); return *this; }
inline gdd& gdd::operator=(aitInt8 d) { put(d); return *this; }
inline gdd& gdd::operator=(aitString d) { put(d); return *this; }
// ----------------- gdd x = primitive data type functions----------------
inline gdd& gdd::operator=(aitFloat64 d)
{ data.Float64=d; setPrimType(aitEnumFloat64); return *this; }
inline gdd& gdd::operator=(aitFloat32 d)
{ data.Float32=d;setPrimType(aitEnumFloat32); return *this; }
inline gdd& gdd::operator=(aitUint32 d)
{ data.Uint32=d; setPrimType(aitEnumUint32); return *this; }
inline gdd& gdd::operator=(aitInt32 d)
{ data.Int32=d; setPrimType(aitEnumInt32); return *this; }
inline gdd& gdd::operator=(aitUint16 d)
{ data.Uint16=d; setPrimType(aitEnumUint16); return *this; }
inline gdd& gdd::operator=(aitInt16 d)
{ data.Int16=d; setPrimType(aitEnumInt16); return *this; }
inline gdd& gdd::operator=(aitUint8 d)
{ data.Uint8=d; setPrimType(aitEnumUint8); return *this; }
inline gdd& gdd::operator=(aitInt8 d)
{ data.Int8=d; setPrimType(aitEnumInt8); return *this; }
inline gdd& gdd::operator=(aitString& d)
{ put(d); return *this; }
inline gdd& gdd::operator=(const aitString& d)
{ put(d); return *this; }
inline gdd::operator aitFloat64*(void) const{ return (aitFloat64*)voidData(); }
inline gdd::operator aitFloat32*(void) const{ return (aitFloat32*)voidData(); }
inline gdd::operator aitUint32*(void) const { return (aitUint32*)voidData(); }
inline gdd::operator aitInt32*(void) const { return (aitInt32*)voidData(); }
inline gdd::operator aitUint16*(void) const { return (aitUint16*)voidData(); }
inline gdd::operator aitInt16*(void) const { return (aitInt16*)voidData(); }
inline gdd::operator aitUint8*(void) const { return (aitUint8*)voidData(); }
inline gdd::operator aitInt8*(void) const { return (aitInt8*)voidData(); }
inline gdd::operator aitString*(void) const { return (aitString*)voidData(); }
// ------------- primitive type pointer = gdd x functions --------------
inline gdd::operator aitFloat64*(void) const
{ return (aitFloat64*)dataPointer(); }
inline gdd::operator aitFloat32*(void) const
{ return (aitFloat32*)dataPointer(); }
inline gdd::operator aitUint32*(void) const
{ return (aitUint32*)dataPointer(); }
inline gdd::operator aitInt32*(void) const
{ return (aitInt32*)dataPointer(); }
inline gdd::operator aitUint16*(void) const
{ return (aitUint16*)dataPointer(); }
inline gdd::operator aitInt16*(void) const
{ return (aitInt16*)dataPointer(); }
inline gdd::operator aitUint8*(void) const
{ return (aitUint8*)dataPointer(); }
inline gdd::operator aitInt8*(void) const
{ return (aitInt8*)dataPointer(); }
inline gdd::operator aitString*(void) const
{ return (aitString*)dataPointer(); }
inline gdd::operator aitFixedString*(void) const
{ return (aitFixedString*)voidData(); }
{ return (aitFixedString*)dataPointer(); }
// ------------- primitive type = gdd x functions --------------
inline gdd::operator aitFloat64(void) { aitFloat64 d; get(d); return d; }
inline gdd::operator aitFloat32(void) { aitFloat32 d; get(d); return d; }
inline gdd::operator aitUint32(void) { aitUint32 d; get(d); return d; }
@@ -986,8 +1134,9 @@ inline gdd::operator aitUint8(void) { aitUint8 d; get(d); return d; }
inline gdd::operator aitInt8(void) { aitInt8 d; get(d); return d; }
inline gdd::operator aitString(void) { aitString d; get(d); return d; }
// ---------------------------------------------------------------------
// ***********************************************************************
// Adds ability to put array data into a DD, get it out, and adjust it
// ***********************************************************************
class gddAtomic : public gdd
{
@@ -1054,14 +1203,24 @@ protected:
// disallow
const gddBounds* getBounds(void) { return NULL; }
gddStatus getBoundingBoxSize(aitUint32*) { return gddErrorNotAllowed; }
gddStatus setBoundingBoxSize(const aitUint32* const)
{ return gddErrorNotAllowed; }
gddStatus getBoundingBoxOrigin(aitUint32*) { return gddErrorNotAllowed; }
gddStatus setBoundingBoxOrigin(const aitUint32* const)
{ return gddErrorNotAllowed; }
gddStatus setBound(int,aitIndex,aitIndex) { return gddErrorNotAllowed; }
gddStatus getBound(int,aitIndex&,aitIndex&) { return gddErrorNotAllowed; }
gddStatus getBoundingBoxSize(aitUint32*) {
gddAutoPrint("gddScalar::getBoundingBoxSize()",gddErrorNotAllowed);
return gddErrorNotAllowed; }
gddStatus setBoundingBoxSize(const aitUint32* const) {
gddAutoPrint("gddScalar::setBoundingBoxSize()",gddErrorNotAllowed);
return gddErrorNotAllowed; }
gddStatus getBoundingBoxOrigin(aitUint32*) {
gddAutoPrint("gddScalar::getBoundingBoxOrigin()",gddErrorNotAllowed);
return gddErrorNotAllowed; }
gddStatus setBoundingBoxOrigin(const aitUint32* const) {
gddAutoPrint("gddScalar::setBoundingBoxOrigin()",gddErrorNotAllowed);
return gddErrorNotAllowed; }
gddStatus setBound(int,aitIndex,aitIndex) {
gddAutoPrint("gddScalar::setBound()",gddErrorNotAllowed);
return gddErrorNotAllowed; }
gddStatus getBound(int,aitIndex&,aitIndex&) {
gddAutoPrint("gddScalar::getBound()",gddErrorNotAllowed);
return gddErrorNotAllowed; }
// disallow
void adjust(aitFloat64* const, gddDestructor*) { }
@@ -1113,9 +1272,15 @@ protected:
~gddContainer(void) { }
void cInit(int num_things_within);
gddStatus changeType(int,aitEnum) { return gddErrorNotAllowed; }
gddStatus setBound(int,aitIndex,aitIndex) { return gddErrorNotAllowed; }
gddStatus getBound(int,aitIndex&,aitIndex&) { return gddErrorNotAllowed; }
gddStatus changeType(int,aitEnum) {
gddAutoPrint("gddContainer::changeType()",gddErrorNotAllowed);
return gddErrorNotAllowed; }
gddStatus setBound(int,aitIndex,aitIndex) {
gddAutoPrint("setBound()",gddErrorNotAllowed);
return gddErrorNotAllowed; }
gddStatus getBound(int,aitIndex&,aitIndex&) {
gddAutoPrint("getBound()",gddErrorNotAllowed);
return gddErrorNotAllowed; }
gddStatus setBound(aitIndex,aitIndex);
private:
@@ -1123,7 +1288,7 @@ private:
};
inline gdd* gddContainer::cData(void) const
{ return (gdd*)voidData(); }
{ return (gdd*)dataPointer(); }
inline int gddContainer::total(void)
{ return bounds->size(); }
inline gdd* gddContainer::operator[](aitIndex index)

View File

@@ -4,6 +4,16 @@
// $Id$
//
// $Log$
// Revision 1.6 1996/08/27 13:05:07 jbk
// final repairs to string functions, put() functions, and error code printing
//
// Revision 1.5 1996/08/22 21:05:42 jbk
// More fixes to make strings and fixed string work better.
//
// Revision 1.4 1996/08/06 19:14:13 jbk
// Fixes to the string class.
// Changes units field to a aitString instead of aitInt8.
//
// Revision 1.3 1996/07/26 02:23:18 jbk
// Fixed the spelling error with Scalar.
//
@@ -47,7 +57,7 @@ void gddApplicationTypeTable::GenerateTypes(void)
// Just describe the menu - allow the block of choiced to be
// referenced in.
gddAtomic* add_enum = new gddAtomic(0,aitEnumFixedString,1);
// gddAtomic* add_enum = new gddAtomic(0,aitEnumFixedString,1,16);
// ----------------------------------------------------------------
// register simple types
@@ -65,6 +75,7 @@ void gddApplicationTypeTable::GenerateTypes(void)
registerApplicationType(GDD_NAME_SEVERITY);
registerApplicationType(GDD_NAME_SECONDS);
registerApplicationType(GDD_NAME_NANOSECONDS);
registerApplicationType(GDD_NAME_PV_NAME);
// required attributes
int type_prec=registerApplicationType(GDD_NAME_PRECISION);
@@ -78,8 +89,11 @@ void gddApplicationTypeTable::GenerateTypes(void)
int type_awlow=registerApplicationType(GDD_NAME_ALARM_WARN_LOW);
int type_maxele=registerApplicationType(GDD_NAME_MAX_ELEMENTS);
int type_value=registerApplicationType(GDD_NAME_VALUE);
int type_menu=registerApplicationType(GDD_NAME_ENUM);
int type_units=registerApplicationTypeWithProto(GDD_NAME_UNITS,add_units);
int type_menu=registerApplicationTypeWithProto(GDD_NAME_ENUM,add_enum);
// old menu method
// int type_menu=registerApplicationType(GDD_NAME_ENUM);
// ----------------------------------------------------------------
// register container types - not as easy
@@ -143,6 +157,7 @@ void gddApplicationTypeTable::GenerateTypes(void)
// DBR_GR_ENUM
gddContainer* cdd_gr_enum=new gddContainer(0);
// old: cdd_gr_enum->insert(new gddAtomic(type_menu,aitEnumFixedString,1));
cdd_gr_enum->insert(getDD(type_menu));
cdd_gr_enum->insert(new gddScalar(type_value,aitEnumEnum16));
registerApplicationTypeWithProto("dbr_gr_enum",cdd_gr_enum);
@@ -215,6 +230,7 @@ void gddApplicationTypeTable::GenerateTypes(void)
// DBR_CTRL_ENUM
gddContainer* cdd_ctrl_enum=new gddContainer(0);
//old:cdd_ctrl_enum->insert(new gddAtomic(type_menu,aitEnumFixedString,1));
cdd_ctrl_enum->insert(getDD(type_menu));
cdd_ctrl_enum->insert(new gddScalar(type_value,aitEnumEnum16));
registerApplicationTypeWithProto("dbr_ctrl_enum",cdd_ctrl_enum);

View File

@@ -29,6 +29,9 @@
*
* History
* $Log$
* Revision 1.2 1996/08/13 23:13:35 jhill
* win NT changes
*
* Revision 1.1 1996/07/10 23:44:12 jhill
* moved here from src/cas/generic
*
@@ -67,7 +70,13 @@ template <class PV>
class gddAppFuncTable {
public:
gddAppFuncTable();
gddAppFuncTable() : pMFuncRead(NULL), appTableNElem(0u) {}
~gddAppFuncTable()
{
if (this->pMFuncRead) {
delete [] this->pMFuncRead;
}
}
//
// typedef for the app read function to be called
@@ -76,23 +85,28 @@ public:
//
// installReadFunc()
// (g++ gags when these are coded outside the class def?)
//
gddAppFuncTableStatus installReadFunc(const unsigned type, gddAppReadFunc pMFuncIn)
gddAppFuncTableStatus installReadFunc(const unsigned type,
gddAppReadFunc pMFuncIn)
{
//
// Attempt to expand the table if the app type will not fit
//
if (type>=this->maxAppType) {
if (type>=this->appTableNElem) {
this->newTbl(type);
if (type>=this->maxAppType) {
if (type>=this->appTableNElem) {
return S_gddAppFuncTable_noMemory;
}
}
this->pMFuncRead[type]=pMFuncIn;
return S_gddAppFuncTable_Success;
}
gddAppFuncTableStatus installReadFunc(const char * const pName, gddAppReadFunc pMFuncIn)
//
// installReadFunc()
//
gddAppFuncTableStatus installReadFunc(const char * const pName,
gddAppReadFunc pMFuncIn)
{
aitUint32 type;
gddStatus rc;
@@ -114,6 +128,7 @@ public:
//
//
gddAppFuncTableStatus read(PV &pv, gdd &value);
gddAppFuncTableStatus callReadFunc (PV &pv, gdd &value);
private:
//
@@ -122,23 +137,11 @@ private:
// expansion of the table)
//
gddAppReadFunc *pMFuncRead;
unsigned maxAppType;
unsigned appTableNElem;
void newTbl(unsigned neMaxType);
};
//
// gddAppFuncTable<PV>::gddAppFuncTable()
//
// The total number of application tags to manage should be
// hidden from the application
//
template <class PV>
inline gddAppFuncTable<PV>::gddAppFuncTable() :
pMFuncRead(NULL),
maxAppType(0u)
{
}
//
// gddAppFuncTable<PV>::newTbl()
@@ -151,35 +154,46 @@ inline void gddAppFuncTable<PV>::newTbl(unsigned newApplTypeMax)
{
gddAppReadFunc *pMNewFuncTbl;
unsigned maxApp;
unsigned i;
if(this->maxAppType>=newApplTypeMax) {
if (this->appTableNElem>newApplTypeMax) {
return;
}
maxApp = newApplTypeMax+(1u<<6u);
pMNewFuncTbl = new gddAppReadFunc[maxApp];
#ifdef _MSC_VER
//
// Right now all MS Visual C++ compilers allocate the
// wrong amount of memory (i.e. too little)
// for member function pointers,
// only explicit calculation via sizeof() works.
// For future versions this may become "if _MSC_VER < ???"...
//
pMNewFuncTbl = (gddAppReadFunc *)
new char[sizeof(gddAppReadFunc) * maxApp];
#else
pMNewFuncTbl = new gddAppReadFunc[maxApp];
#endif
if (pMNewFuncTbl) {
if (this->pMFuncRead) {
memcpy( pMNewFuncTbl,
this->pMFuncRead,
this->maxAppType*sizeof(*pMNewFuncTbl));
delete [] this->pMFuncRead;
memset(&pMNewFuncTbl[this->maxAppType], 0,
(maxApp-this->maxAppType) *
sizeof(*pMNewFuncTbl));
for (i=0u; i<maxApp; i++) {
if (i<this->appTableNElem) {
pMNewFuncTbl[i] = this->pMFuncRead[i];
}
else {
//
// some versions of NULL include (void *) cast
// (so I am using vanilla zero here)
//
pMNewFuncTbl[i] = 0;
}
}
else {
memset(pMNewFuncTbl, 0,
maxApp * sizeof(*pMNewFuncTbl));
if (this->pMFuncRead) {
delete [] this->pMFuncRead;
}
this->pMFuncRead = pMNewFuncTbl;
this->maxAppType = maxApp;
this->appTableNElem = maxApp;
}
}
//
// gddAppFuncTable<PV>::installReadFunc()
//
//
// gddAppFuncTable<PV>::read()
@@ -191,8 +205,6 @@ template <class PV>
inline gddAppFuncTableStatus gddAppFuncTable<PV>::read(PV &pv, gdd &value)
{
gddAppFuncTableStatus status;
gddAppReadFunc pFunc;
unsigned type;
//
// if this gdd is a container then step through it
@@ -213,13 +225,24 @@ inline gddAppFuncTableStatus gddAppFuncTable<PV>::read(PV &pv, gdd &value)
}
return status;
}
return callReadFunc(pv, value);
}
//
// gddAppFuncTable<PV>::callReadFunc()
//
template <class PV>
inline gddAppFuncTableStatus gddAppFuncTable<PV>::callReadFunc (PV &pv, gdd &value)
{
unsigned type = value.applicationType();
gddAppReadFunc pFunc;
//
// otherwise call the function associated
// with this application type
//
type = value.applicationType();
if (type>=this->maxAppType) {
if (type>=this->appTableNElem) {
errPrintf (S_gddAppFuncTable_badType, __FILE__,
__LINE__, "- large appl type code = %u\n",
type);
@@ -232,7 +255,6 @@ inline gddAppFuncTableStatus gddAppFuncTable<PV>::read(PV &pv, gdd &value)
type);
return S_gddAppFuncTable_badType;
}
status = (pv.*pFunc)(value);
return status;
return (pv.*pFunc)(value);
}

View File

@@ -4,6 +4,10 @@
// $Id$
//
// $Log$
// Revision 1.2 1996/06/26 21:00:08 jbk
// Fixed up code in aitHelpers, removed unused variables in others
// Fixed potential problem in gddAppTable.cc with the map functions
//
// Revision 1.1 1996/06/25 19:11:41 jbk
// new in EPICS base
//
@@ -215,9 +219,15 @@ gddStatus gddApplicationTypeTable::registerApplicationType(
gddStatus rc;
if(new_app=getApplicationType(name))
{
// gddAutoPrint(gddErrorAlreadyDefined);
return gddErrorAlreadyDefined;
}
if(total_registered>max_allowed)
{
gddAutoPrint("gddAppTable::registerApplicationType()",gddErrorAtLimit);
return gddErrorAtLimit;
}
sem.take();
rapp=total_registered++;
@@ -229,7 +239,10 @@ gddStatus gddApplicationTypeTable::registerApplicationType(
{
// group already allocated - check is app already refined
if(attr_table[group][app].type!=gddApplicationTypeUndefined)
{
// gddAutoPrint(gddErrorAlreadyDefined);
return gddErrorAlreadyDefined;
}
}
else
{
@@ -346,17 +359,21 @@ gddStatus gddApplicationTypeTable::mapAppToIndex(
aitUint32 c_app, aitUint32 m_app, aitUint32& x)
{
aitUint32 group,app;
gddStatus rc;
gddStatus rc=0;
if((rc=splitApplicationType(c_app,group,app))<0) return rc;
if(attr_table[group][app].map && m_app<attr_table[group][app].map_size)
if((rc=splitApplicationType(c_app,group,app))==0)
{
x=attr_table[group][app].map[m_app];
return 0;
if(attr_table[group][app].map && m_app<attr_table[group][app].map_size)
{
x=attr_table[group][app].map[m_app];
if(x==0 && c_app!=m_app)
rc=gddErrorNotDefined;
}
else
rc=gddErrorOutOfBounds;
}
else
return gddErrorOutOfBounds;
gddAutoPrint("gddAppTable::mapAppToIndex()",rc);
return rc;
}
gdd* gddApplicationTypeTable::getDD(aitUint32 rapp)
@@ -433,15 +450,17 @@ gddStatus gddApplicationTypeTable::freeDD(gdd* dd)
gddStatus gddApplicationTypeTable::storeValue(aitUint32 ap, aitUint32 uv)
{
aitUint32 group,app;
gddStatus rc;
gddStatus rc=0;
if((rc=splitApplicationType(ap,group,app))<0) return rc;
if(attr_table[group]==NULL ||
attr_table[group][app].type==gddApplicationTypeUndefined)
return gddErrorNotDefined;
rc=gddErrorNotDefined;
else
attr_table[group][app].user_value=uv;
attr_table[group][app].user_value=uv;
return 0;
gddAutoPrint("gddAppTable::storeValue()",rc);
return rc;
}
aitUint32 gddApplicationTypeTable::getValue(aitUint32 ap)
@@ -522,6 +541,9 @@ gddStatus gddApplicationTypeTable::smartCopy(gdd* dest, gdd* src)
{
gddStatus rc=0;
// only works with managed containers because app table mapping
// feature is used.
if(dest->isContainer() && dest->isManaged())
rc=copyDD_src(dest,src);
else if(src->isContainer() && src->isManaged())
@@ -531,5 +553,6 @@ gddStatus gddApplicationTypeTable::smartCopy(gdd* dest, gdd* src)
else
rc=gddErrorNotAllowed;
gddAutoPrint("gddAppTable::smartCopy()",rc);
return rc;
}

View File

@@ -8,6 +8,12 @@
* $Id$
*
* $Log$
* Revision 1.2 1996/08/27 13:05:09 jbk
* final repairs to string functions, put() functions, and error code printing
*
* Revision 1.1 1996/06/25 19:11:42 jbk
* new in EPICS base
*
*
* *Revision 1.3 1996/06/24 03:15:36 jbk
* *name changes and fixes for aitString and fixed string functions
@@ -48,7 +54,7 @@
#define GDD_NAME_NANOSECONDS "nanoseconds"
#define GDD_NAME_ALL "all"
#define GDD_NAME_ATTRIBUTES "attributes"
#define GDD_NAME_PV_NAME "name"
typedef enum
{
gddApplicationTypeUndefined,
@@ -167,9 +173,15 @@ inline aitUint32 gddApplicationTypeTable::index(aitUint32 rapp) const
inline gddStatus gddApplicationTypeTable::splitApplicationType(aitUint32 rapp,
aitUint32& g, aitUint32& app) const
{
gddStatus rc=0;
g=group(rapp);
app=index(rapp);
if(rapp>=total_registered) return gddErrorOutOfBounds; else return 0;
if(rapp>=total_registered)
{
rc=gddErrorOutOfBounds;
gddAutoPrint("gddAppTable::splitApplicationType()",rc);
}
return rc;
}
inline aitUint32 gddApplicationTypeTable::registerApplicationType(

View File

@@ -8,6 +8,9 @@
* $Id$
*
* $Log$
* Revision 1.1 1996/06/25 19:11:43 jbk
* new in EPICS base
*
*
* *Revision 1.2 1996/06/13 21:32:00 jbk
* *Various fixes and correction - including ref_cnt change to unsigned short
@@ -16,6 +19,11 @@
*
*/
/*
gdd.cc contains a table (gddErrorMessages) that has all the text
strings for each of the error codes
*/
typedef long gddStatus;
#define gddErrorTypeMismatch -1
@@ -29,4 +37,20 @@ typedef long gddStatus;
#define gddErrorOverflow -9
#define gddErrorUnderflow -10
extern char* gddErrorMessages[];
#define gddPrintError(x) \
fprintf(stderr,"gdd Error: %s\n",gddErrorMessages[x*(-1)]);
#define gddPrintErrorWithMessage(msg,x) \
fprintf(stderr,"gdd Error: %s (%s)\n",gddErrorMessages[x*(-1)],msg);
#define gddGetErrorMessage(x) gddErrorMessages[x*(-1)]
#ifdef GDDAUTOPRINT
#define gddAutoPrint(s,x) if(x) gddPrintErrorWithMessage(s,x)
#else
#define gddAutoPrint(s,x) ;
#endif
#endif

View File

@@ -4,6 +4,9 @@
// $Id$
//
// $Log$
// Revision 1.2 1996/07/26 02:23:18 jbk
// Fixed the spelling error with Scalar.
//
// Revision 1.1 1996/06/25 19:11:48 jbk
// new in EPICS base
//
@@ -21,9 +24,6 @@
// -----------------------test routines------------------------
#ifdef NO_DUMP_TEST
void gdd::dump(void) { }
#else
void gdd::dump(void)
{
gddScalar* sdd;
@@ -49,26 +49,186 @@ void gdd::dump(void)
return;
}
}
#endif
#ifdef NO_DUMP_TEST
void gdd::dumpInfo(void) { }
#else
void gdd::dumpInfo(void)
{
unsigned i;
aitIndex f,c;
long sz_tot,sz_data,sz_elem;
const aitIndex max=5;
aitIndex prt_tot;
sz_tot = getTotalSizeBytes();
sz_data = getDataSizeBytes();
sz_elem = getDataSizeElements();
prt_tot=sz_elem>max?max:sz_elem;
fprintf(stderr,"----------dump This=%8.8x---------\n",(unsigned int)this);
fprintf(stderr," app=%d, prim=%d",applicationType(),primitiveType());
fprintf(stderr," dim=%d\n",dimension());
fprintf(stderr," tot=%ld, data=%ld, elem=%ld ",sz_tot,sz_data,sz_elem);
fprintf(stderr," ref count=%d\n",ref_cnt);
fprintf(stderr," dimension=%d ",(int)dimension());
fprintf(stderr,"app-type=%d ",(int)applicationType());
if(isScalar()) fprintf(stderr,"Scalar\n");
if(isAtomic()) fprintf(stderr,"Atomic\n");
if(isContainer()) fprintf(stderr,"Container\n");
fprintf(stderr," prim-type=%d",(int)primitiveType());
switch(primitiveType())
{
case aitEnumInvalid:
fprintf(stderr,"(aitEnumInvalid)");
break;
case aitEnumInt8:
fprintf(stderr,"(aitEnumInt8)");
if(isScalar()) fprintf(stderr," value=0x%2.2x ",data.Int8);
if(isAtomic()&&dataPointer())
{
fprintf(stderr,"\n %d values=<\n",(int)prt_tot);
aitInt8* i8=(aitInt8*)dataPointer();
for(i=0;i<prt_tot;i++) fprintf(stderr,"0x%2.2x ",i8[i]);
fprintf(stderr,">\n");
}
break;
case aitEnumInt16:
fprintf(stderr,"(aitEnumInt16)");
if(isScalar()) fprintf(stderr," value=%hd ",data.Int16);
if(isAtomic()&&dataPointer())
{
fprintf(stderr,"\n %d values=<\n",(int)prt_tot);
aitInt16* i16=(aitInt16*)dataPointer();
for(i=0;i<prt_tot;i++) fprintf(stderr,"%hd ",i16[i]);
fprintf(stderr,">\n");
}
break;
case aitEnumInt32:
fprintf(stderr,"(aitEnumInt32)");
if(isScalar()) fprintf(stderr," value=%d ",data.Int32);
if(isAtomic()&&dataPointer())
{
fprintf(stderr,"\n %d values=<\n",(int)prt_tot);
aitInt32* i32=(aitInt32*)dataPointer();
for(i=0;i<prt_tot;i++) fprintf(stderr,"%d ",i32[i]);
fprintf(stderr,">\n");
}
break;
case aitEnumUint8:
fprintf(stderr,"(aitEnumUint8)");
if(isScalar()) fprintf(stderr," value=0x%2.2x ",data.Uint8);
if(isAtomic()&&dataPointer())
{
fprintf(stderr,"\n %d values=<\n",(int)prt_tot);
aitUint8* ui8=(aitUint8*)dataPointer();
for(i=0;i<prt_tot;i++) fprintf(stderr,"0x%2.2x ",ui8[i]);
fprintf(stderr,">\n");
}
break;
case aitEnumUint16:
fprintf(stderr,"(aitEnumUint16)");
if(isScalar()) fprintf(stderr," value=%hu ",data.Uint16);
if(isAtomic()&&dataPointer())
{
fprintf(stderr,"\n %d values=<\n",(int)prt_tot);
aitUint16* ui16=(aitUint16*)dataPointer();
for(i=0;i<prt_tot;i++) fprintf(stderr,"%hu ",ui16[i]);
fprintf(stderr,">\n");
}
break;
case aitEnumEnum16:
fprintf(stderr,"(aitEnumEnum16)");
if(isScalar()) fprintf(stderr," value=%hu ",data.Enum16);
if(isAtomic()&&dataPointer())
{
fprintf(stderr,"\n %d values=<\n",(int)prt_tot);
aitEnum16* e16=(aitEnum16*)dataPointer();
for(i=0;i<prt_tot;i++) fprintf(stderr,"%hu ",e16[i]);
fprintf(stderr,">\n");
}
break;
case aitEnumUint32:
fprintf(stderr,"(aitEnumUint32)");
if(isScalar()) fprintf(stderr," value=%u ",data.Uint32);
if(isAtomic()&&dataPointer())
{
fprintf(stderr,"\n %d values=<\n",(int)prt_tot);
aitUint32* ui32=(aitUint32*)dataPointer();
for(i=0;i<prt_tot;i++) fprintf(stderr,"%u ",ui32[i]);
fprintf(stderr,">\n");
}
break;
case aitEnumFloat32:
fprintf(stderr,"(aitEnumFloat32)");
if(isScalar()) fprintf(stderr," value=%f ",data.Float32);
if(isAtomic()&&dataPointer())
{
fprintf(stderr,"\n %d values=<\n",(int)prt_tot);
aitFloat32* f32=(aitFloat32*)dataPointer();
for(i=0;i<prt_tot;i++) fprintf(stderr,"%f ",f32[i]);
fprintf(stderr,">\n");
}
break;
case aitEnumFloat64:
fprintf(stderr,"(aitEnumFloat64)");
if(isScalar()) fprintf(stderr," value=%lf ",data.Float64);
if(isAtomic()&&dataPointer())
{
fprintf(stderr,"\n %d values=<\n",(int)prt_tot);
aitFloat64* f64=(aitFloat64*)dataPointer();
for(i=0;i<prt_tot;i++) fprintf(stderr,"%lf ",f64[i]);
fprintf(stderr,">\n");
}
break;
case aitEnumFixedString:
fprintf(stderr,"(aitEnumFixedString)");
if(isScalar())
{
if(data.FString)
fprintf(stderr," value=<%s>\n",data.FString);
else
fprintf(stderr," value=<NULL>\n");
}
if(isAtomic()&&dataPointer())
{
fprintf(stderr,"\n %d values=<\n",(int)prt_tot);
aitFixedString* fs=(aitFixedString*)dataPointer();
for(i=0;i<prt_tot;i++) fprintf(stderr,"<%s> ",fs[i].fixed_string);
fprintf(stderr,">\n");
}
break;
case aitEnumString:
fprintf(stderr,"(aitEnumString)");
if(isScalar())
{
aitString* str = (aitString*)dataAddress();
fprintf(stderr,"\n");
str->dump();
}
if(isAtomic()&&dataPointer())
{
fprintf(stderr,"\n %d values=<\n",(int)prt_tot);
aitString* ss=(aitString*)dataPointer();
for(i=0;i<prt_tot;i++)
if(ss[i].string()) fprintf(stderr,"<%s> ",ss[i].string());
fprintf(stderr,">\n");
}
break;
case aitEnumContainer:
fprintf(stderr,"(aitEnumContainer)");
break;
default: break;
}
fprintf(stderr," ref-count=%d\n",ref_cnt);
fprintf(stderr," total-bytes=%ld,",sz_tot);
fprintf(stderr," data-size=%ld,",sz_data);
fprintf(stderr," element-count=%ld\n",sz_elem);
if(!isScalar())
{
if(destruct)
fprintf(stderr," destructor=%8.8x\n",(int)destruct);
else
fprintf(stderr," destructor=NULL\n",(int)destruct);
}
for(i=0;i<dimension();i++)
{
@@ -76,139 +236,50 @@ void gdd::dumpInfo(void)
fprintf(stderr," (%d) %8.8x first=%d count=%d\n",i,&bounds[i],f,c);
}
if(isScalar()) fprintf(stderr," Is a Scalar\n");
if(isAtomic()) fprintf(stderr," Is a Atomic\n");
if(isContainer()) fprintf(stderr," Is a Container\n");
if(isManaged()) fprintf(stderr," Managed");
if(isFlat()) fprintf(stderr," Flat");
if(isNetworkByteOrder()) fprintf(stderr," NetworkByteOrder");
if(isConstant()) fprintf(stderr," Constant");
if(isNoRef()) fprintf(stderr," NoReferencing");
fprintf(stderr,"\n");
if(!isContainer() && !isScalar() && !isAtomic())
fprintf(stderr,"--------------------------------------\n");
}
#endif
#ifdef NO_DUMP_TEST
void gddAtomic::dump(void) { }
#else
void gddAtomic::dump(void)
{
aitFloat64* f64; aitFloat32* f32;
aitUint32* ui32; aitInt32* i32;
aitUint16* ui16; aitInt16* i16;
aitUint8* ui8; aitInt8* i8;
char* str;
gdd::dumpInfo();
switch(primitiveType())
{
case aitEnumFloat64:
getRef(f64);
if(f64) fprintf(stderr," Convert: float64 %8.8x %lf ",f64,f64[0]);
f64=*this;
if(f64) fprintf(stderr," Normal: float64 %8.8x %lf\n",f64,f64[0]);
break;
case aitEnumFloat32:
getRef(f32);
if(f32) fprintf(stderr," Convert: float32 %8.8x %f ",f32,f32[0]);
f32=*this;
if(f32) fprintf(stderr," Normal: float32 %8.8x %f\n",f32,f32[0]);
break;
case aitEnumUint32:
getRef(ui32);
if(ui32) fprintf(stderr," Convert: uint32 %8.8x %d ",ui32,ui32[0]);
ui32=*this;
if(ui32) fprintf(stderr," Normal: uint32 %8.8x %d\n",ui32,ui32[0]);
break;
case aitEnumInt32:
getRef(i32);
if(i32) fprintf(stderr," Convert: int32 %8.8x %d ",i32,i32[0]);
i32=*this;
if(i32) fprintf(stderr," Normal: int32 %8.8x %d\n",i32,i32[0]);
break;
case aitEnumUint16:
getRef(ui16);
if(ui16) fprintf(stderr," Convert: uint16 %8.8x %hu ",ui16,ui16[0]);
ui16=*this;
if(ui16) fprintf(stderr," Normal: uint16 %8.8x %hu\n",ui16,ui16[0]);
break;
case aitEnumInt16:
getRef(i16);
if(i16) fprintf(stderr," Convert: int16 %8.8x %hd ",i16,i16[0]);
i16=*this;
if(i16) fprintf(stderr," Normal: int16 %8.8x %hd\n",i16,i16[0]);
break;
case aitEnumUint8:
getRef(ui8);
if(ui8) fprintf(stderr," Convert: uint8 %8.8x %d ",ui8,ui8[0]);
ui8=*this;
if(ui8) fprintf(stderr," Normal: uint8 %8.8x %d\n",ui8,ui8[0]);
break;
case aitEnumInt8:
getRef(i8);
if(i8) fprintf(stderr," Convert: int8 %8.8x %d ",i8,i8[0]);
i8=*this;
if(i8) fprintf(stderr," Normal: int8 %8.8x %d\n",i8,i8[0]);
break;
case aitEnumString:
getRef(str);
if(str) fprintf(stderr," <%s>\n",str);
break;
default:
fprintf(stderr," unknown primitive type\n"); break;
}
fprintf(stderr,"-------------------------------------\n");
}
#endif
#ifdef NO_DUMP_TEST
void gddScalar::dump(void) { }
#else
void gddScalar::dump(void)
{
aitFloat64 f64; aitFloat32 f32; aitUint32 ui32; aitInt32 i32;
aitUint16 ui16; aitInt16 i16; aitUint8 ui8; aitInt8 i8;
gdd::dumpInfo();
switch(primitiveType())
{
case aitEnumFloat64:
get(f64); if(f64) fprintf(stderr," Convert: float64 %lf ",f64);
f64=*this; if(f64) fprintf(stderr," Normal: float64 %lf\n",f64);
break;
case aitEnumFloat32:
get(f32); if(f32) fprintf(stderr," Convert: float32 %f ",f32);
f32=*this; if(f32) fprintf(stderr," Normal: float32 %f\n",f32);
break;
case aitEnumUint32:
get(ui32); if(ui32) fprintf(stderr," Convert: uint32 %d ",ui32);
ui32=*this; if(ui32) fprintf(stderr," Normal: uint32 %d\n",ui32);
break;
case aitEnumInt32:
get(i32); if(i32) fprintf(stderr," Convert: int32 %d ",i32);
i32=*this; if(i32) fprintf(stderr," Normal: int32 %d\n",i32);
break;
case aitEnumUint16:
get(ui16); if(ui16) fprintf(stderr," Convert: uint16 %hu ",ui16);
ui16=*this; if(ui16) fprintf(stderr," Normal: uint16 %hu\n",ui16);
break;
case aitEnumInt16:
get(i16); if(i16) fprintf(stderr," Convert: int16 %hd ",i16);
i16=*this; if(i16) fprintf(stderr," Normal: int16 %hd\n",i16);
break;
case aitEnumUint8:
get(ui8); if(ui8) fprintf(stderr," Convert: uint8 %2.2x ",ui8);
ui8=*this; if(ui8) fprintf(stderr," Normal: uint8 %2.2x\n",ui8);
break;
case aitEnumInt8:
get(i8); if(i8) fprintf(stderr," Convert: int8 %d ",i8);
i8=*this; if(i8) fprintf(stderr," Normal: int8 %d\n",i8);
break;
default:
fprintf(stderr," unknown primitive type\n"); break;
}
fprintf(stderr,"--------------------------------------\n");
}
#endif
void gddAtomic::dump(void)
{
gdd::dumpInfo();
fprintf(stderr,"-------------------------------------\n");
}
void gddContainer::dump(void)
{
int i;
gdd* dd;
gddAtomic* add;
gddScalar* sdd;
gddContainer* cdd;
fprintf(stderr,"----------dumping container:\n");
gdd::dumpInfo();
fprintf(stderr," total in container = %d\n",total());
// should use a cursor
for(i=0;dd=getDD(i);i++)
{
if(dd->isAtomic()) { add=(gddAtomic*)dd; add->dump(); }
if(dd->isScalar()) { sdd=(gddScalar*)dd; sdd->dump(); }
if(dd->isContainer()) { cdd=(gddContainer*)dd; cdd->dump(); }
}
}
#ifdef NO_DUMP_TEST
void gdd::test() { }
@@ -395,32 +466,6 @@ void gddScalar::test(void)
}
#endif
#ifdef NO_DUMP_TEST
void gddContainer::dump(void) { }
#else
void gddContainer::dump(void)
{
int i;
gdd* dd;
gddAtomic* add;
gddScalar* sdd;
gddContainer* cdd;
fprintf(stderr,"----------dumping container:\n");
gdd::dumpInfo();
fprintf(stderr," total in container = %d\n",total());
// should use a cursor
for(i=0;dd=getDD(i);i++)
{
if(dd->isAtomic()) { add=(gddAtomic*)dd; add->dump(); }
if(dd->isScalar()) { sdd=(gddScalar*)dd; sdd->dump(); }
if(dd->isContainer()) { cdd=(gddContainer*)dd; cdd->dump(); }
}
}
#endif
#ifdef NO_DUMP_TEST
void gddContainer::test(void) { }
#else

View File

@@ -6,6 +6,6 @@
#define EPICS_MODIFICATION 0
#define EPICS_UPDATE_LEVEL 5
#define epicsReleaseVersion "@(#)Version R3.13.0.beta1 $Date$"
#define epicsReleaseVersion "@(#)Version R3.13.0.beta2 $Date$"
#define EPICS_VERSION_STRING "EPICS Version 3.13.0.beta1"
#define EPICS_VERSION_STRING "EPICS Version 3.13.0.beta2"

View File

@@ -0,0 +1,28 @@
/*
* Solaris specifif socket include
*/
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <sys/filio.h>
#include <sys/sockio.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#ifdef __cplusplus
}
#endif
typedef int SOCKET;
#define SOCKERRNO errno
#define socket_close(S) close(S)
#define socket_ioctl(A,B,C) ioctl(A,B,C)

View File

@@ -0,0 +1,80 @@
/*
* sun4 specific socket include
*/
#ifndef SUNOS4
#errro this is a SUNOS4 specific socket include
#endif
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
int ioctl (int fd, int req, ...);
int close (int fd);
int gettimeofday (struct timeval *tp, struct timezone *tzp);
int gethostname (char *name, int namelen);
/*
* sun's CC defines at least a few of these under sunos4
*/
#if defined(__SUNPRO_CC)
# include <arpa/inet.h>
#else
int listen (int socket, int backlog);
int accept (int socket, struct sockaddr *addr, int *addrlen);
int shutdown (int socket, int how);
int getpeername (int socket, struct sockaddr *name, int *namelen);
int connect (int socket, struct sockaddr *name, int namelen);
int setsockopt (int socket, int level, int optname,
char *optval, int optlen);
void bzero (char *b, int length);
int sendto (int socket, const char *buf, int len,
int flags, struct sockaddr *to, int tolen);
int select (int width, fd_set *readfds, fd_set *writefds,
fd_set *exceptfds, struct timeval *timeout);
int bind (int socket, struct sockaddr *name, int namelen);
int send (int socket, const char *buf, int len, int flags);
int recv (int socket, char *buf, int len, int flags);
int getsockopt (int socket, int level, int optname,
char *optval, int *optlen);
int socket (int domain, int type, int protocol);
int recvfrom (int socket, char *buf, int len,
int flags, struct sockaddr *from, int *fromlen);
int getsockname (int socket, struct sockaddr *name, int *namelen);
/*
* from /usr/include/arpa/inet.h
* (which under sunos4 does not include arguments for C++)
* (__SUNPRO_CC supplies this file but g++ does not supply an ansi protottype)
*/
unsigned long inet_addr (char *);
char * inet_ntoa (struct in_addr in);
/*
* from /usr/include/netdb.h
* (which under sunos4 does not include arguments for C++)
* (__SUNPRO_CC supplies this file but g++ does not)
*/
struct hostent *gethostbyaddr(char *addr, int len, int type);
#endif /* !defined(__SUNPRO_CC) */
#ifdef __cplusplus
}
#endif
typedef int SOCKET;
#define SOCKERRNO errno
#define socket_close(S) close(S)
#define socket_ioctl(A,B,C) ioctl(A,B,C)

View File

@@ -0,0 +1,26 @@
/*
* vxWorks specific socket include
*/
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/socket.h>
#include <sockLib.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#ifdef __cplusplus
}
#endif
typedef int SOCKET;
#define SOCKERRNO errno
#define socket_close(S) close(S)
#define socket_ioctl(A,B,C) ioctl(A,B,(int)C)

View File

@@ -0,0 +1,21 @@
OUTPUT_FORMAT("a.out-sunos-big")
OUTPUT_ARCH(m68k)
__DYNAMIC = 0;
SECTIONS
{
.text 0x00:
{
CREATE_OBJECT_SYMBOLS
*(.text)
}
.data SIZEOF(.text) + ADDR(.text) :
{
*(.data)
CONSTRUCTORS
}
.bss SIZEOF(.data) + ADDR(.data) :
{
*(.bss)
*(COMMON)
}
}

View File

@@ -3,9 +3,6 @@ include $(TOP)/config/CONFIG_BASE
LINK.c=$(LD) $(LDFLAGS)
# JRW -- Don't define a SRCS.c or SRCS.cc if it is empty
# SRCS.c =
IOC_CORE_OBJS = \
$(TOP)/src/as/O.$(T_A)/asLibrary \
$(TOP)/src/dbStatic/O.$(T_A)/dbStaticLib \
@@ -18,19 +15,16 @@ IOC_CORE_OBJS = \
$(TOP)/src/dbtools/O.$(T_A)/dbSubs \
$(TOP)/src/bpt/O.$(T_A)/pbtLib
PROD = iocCore vxWorks vxWorks.sym
PROD = iocCore
vpath vxWorks% $(VX_CONFIG_DIR)/$(T_A)
INSTALLS = vxWorks vxWorks.sym
include $(TOP)/config/RULES.Vx
vxWorks: $(VX_IMAGE)
@$(RM) $@
@cp -p $< .
vxWorks.sym: $(VX_IMAGE_SYM)
@$(RM) $@
@cp -p $< .
iocCore: $(IOC_CORE_OBJS)
$(LINK.c) $@ $(IOC_CORE_OBJS)
ifneq ($(HOST_ARCH),WIN32)
@what $@
endif

View File

@@ -29,6 +29,9 @@
*
* History
* $Log$
* Revision 1.4 1996/08/05 19:31:59 jhill
* fixed removes use of iter.cur()
*
* Revision 1.3 1996/07/25 17:58:16 jhill
* fixed missing ref in list decl
*
@@ -58,6 +61,9 @@ typedef unsigned resTableIndex;
const unsigned resTableIndexBitWidth = (sizeof(resTableIndex)*CHAR_BIT);
//
// class T must derive class ID
//
template <class T, class ID>
class resTable {
public:
@@ -106,7 +112,6 @@ public:
while (pList<&this->pTable[this->hashIdMask+1]) {
tsSLIter<T> iter(*pList);
T *pItem;
while ( (pItem = iter()) ) {
iter.remove();
delete pItem;
@@ -248,7 +253,7 @@ private:
//
class uintId {
public:
uintId(unsigned idIn=~0u) : id(idIn) {}
uintId(unsigned idIn=UINT_MAX) : id(idIn) {}
resTableIndex resourceHash(unsigned nBitsId) const
{
@@ -267,7 +272,7 @@ public:
//
return hashid;
}
int operator == (const uintId &idIn)
{
return this->id == idIn.id;
@@ -287,11 +292,15 @@ protected:
template <class ITEM>
class uintRes : public uintId, public tsSLNode<ITEM> {
friend class uintResTable<ITEM>;
public:
uintRes(unsigned idIn=UINT_MAX) : uintId(idIn) {}
};
//
// special resource table which uses
// unsigned integer keys allocated in chronological sequence
//
// NOTE: ITEM must public inherit from uintRes<ITEM>
//
template <class ITEM>
class uintResTable : public resTable<ITEM, uintId> {
@@ -360,17 +369,33 @@ private:
//
class stringId {
public:
stringId (char const * const idIn) : id(idIn) {}
stringId (char const * const idIn) :
pStr(new char [strlen(idIn)+1u])
{
if (this->pStr!=NULL) {
strcpy(this->pStr, idIn);
}
}
~ stringId()
{
if (this->pStr!=NULL) {
delete [] this->pStr;
}
}
resTableIndex resourceHash(unsigned nBitsId) const
{
const char *pStr = this->id;
resTableIndex hashid;
unsigned i;
if (this->pStr==NULL) {
return 0u;
}
hashid = 0u;
for (i=0u; pStr[i]; i++) {
hashid += pStr[i] * (i+1u);
for (i=0u; this->pStr[i]; i++) {
hashid += this->pStr[i] * (i+1u);
}
hashid = hashid % (1u<<nBitsId);
@@ -380,20 +405,25 @@ public:
int operator == (const stringId &idIn)
{
return strcmp(this->id,idIn.id)==0;
if (this->pStr!=NULL && idIn.pStr!=NULL) {
return strcmp(this->pStr,idIn.pStr)==0;
}
else {
return 0u; // not equal
}
}
const char * resourceName()
{
return id;
return this->pStr;
}
void show (unsigned)
{
printf ("resource id = %s\n", id);
printf ("resource id = %s\n", this->pStr);
}
private:
char const * const id;
char * const pStr;
};
#endif // INCresourceLibh

View File

@@ -23,68 +23,127 @@ private:
const char * const pName;
};
class jane : public stringId, tsSLNode<jane> {
public:
jane (const char *pNameIn) : stringId(pNameIn) {}
};
main()
{
unsigned i;
clock_t start, finish;
double duration;
const int LOOPS = 500000;
resTable<fred,uintId> tbl;
const int LOOPS = 50000;
resTable<fred,uintId> intTbl;
resTable<jane,stringId> strTbl;
fred fred1("fred1",0x1000a432);
fred fred2("fred2",0x0000a432);
jane jane1("jane1");
jane jane2("jane2");
fred *pFred;
uintId id1(0x1000a432);
uintId id2(0x0000a432);
jane *pJane;
uintId uintId1(0x1000a432);
uintId uintId2(0x0000a432);
stringId strId1("jane1");
stringId strId2("jane2");
int status;
status = tbl.init(8);
status = intTbl.init(8);
if (status) {
return -1;
}
status = tbl.add(fred1);
status = intTbl.add(fred1);
assert (!status);
status = tbl.add(fred2);
status = intTbl.add(fred2);
assert (!status);
start = clock();
for(i=0; i<LOOPS; i++){
pFred = tbl.lookup(id1);
pFred = intTbl.lookup(uintId1);
assert(pFred==&fred1);
pFred = tbl.lookup(id1);
pFred = intTbl.lookup(uintId1);
assert(pFred==&fred1);
pFred = tbl.lookup(id1);
pFred = intTbl.lookup(uintId1);
assert(pFred==&fred1);
pFred = tbl.lookup(id1);
pFred = intTbl.lookup(uintId1);
assert(pFred==&fred1);
pFred = tbl.lookup(id1);
pFred = intTbl.lookup(uintId1);
assert(pFred==&fred1);
pFred = tbl.lookup(id1);
pFred = intTbl.lookup(uintId1);
assert(pFred==&fred1);
pFred = tbl.lookup(id1);
pFred = intTbl.lookup(uintId1);
assert(pFred==&fred1);
pFred = tbl.lookup(id1);
pFred = intTbl.lookup(uintId1);
assert(pFred==&fred1);
pFred = tbl.lookup(id1);
pFred = intTbl.lookup(uintId1);
assert(pFred==&fred1);
pFred = tbl.lookup(id2);
pFred = intTbl.lookup(uintId2);
assert(pFred==&fred2);
}
finish = clock();
duration = finish-start;
duration /= CLOCKS_PER_SEC;
printf("It took %15.10f total sec\n", duration);
printf("It took %15.10f total sec for integer hash lookups\n", duration);
duration /= LOOPS;
duration /= 10;
duration *= 1e6;
printf("It took %15.10f u sec per hash lookup\n", duration);
printf("It took %15.10f u sec per integer hash lookup\n", duration);
tbl.show(10u);
intTbl.show(10u);
tbl.remove(id1);
tbl.remove(id2);
intTbl.remove(uintId1);
intTbl.remove(uintId2);
status = strTbl.init(8);
if (status) {
return -1;
}
status = strTbl.add(jane1);
assert (!status);
status = strTbl.add(jane2);
assert (!status);
start = clock();
for(i=0; i<LOOPS; i++){
pJane = strTbl.lookup(strId1);
assert(pJane==&jane1);
pJane = strTbl.lookup(strId1);
assert(pJane==&jane1);
pJane = strTbl.lookup(strId1);
assert(pJane==&jane1);
pJane = strTbl.lookup(strId1);
assert(pJane==&jane1);
pJane = strTbl.lookup(strId1);
assert(pJane==&jane1);
pJane = strTbl.lookup(strId1);
assert(pJane==&jane1);
pJane = strTbl.lookup(strId1);
assert(pJane==&jane1);
pJane = strTbl.lookup(strId1);
assert(pJane==&jane1);
pJane = strTbl.lookup(strId1);
assert(pJane==&jane1);
pJane = strTbl.lookup(strId2);
assert(pJane==&jane2);
}
finish = clock();
duration = finish-start;
duration /= CLOCKS_PER_SEC;
printf("It took %15.10f total sec for string hash lookups\n", duration);
duration /= LOOPS;
duration /= 10;
duration *= 1e6;
printf("It took %15.10f u sec per string hash lookup\n", duration);
strTbl.show(10u);
strTbl.remove(strId1);
strTbl.remove(strId2);
return 0;
}

View File

@@ -31,6 +31,9 @@
*
* History
* $Log$
* Revision 1.3 1996/07/25 18:01:42 jhill
* use pointer (not ref) for list in iter class
*
* Revision 1.2 1996/07/24 22:12:04 jhill
* added remove() to iter class + made node's prev/next private
*
@@ -125,7 +128,7 @@ template <class T>
class tsSLIter {
public:
tsSLIter(tsSLList<T> &listIn) :
pList(&listIn), pCurrent(0), pPrevious(0) {}
pCurrent(0), pPrevious(0), pList(&listIn) {}
void reset()
{

View File

@@ -28,6 +28,9 @@
* -----------------
* .01 02-16-95 mrk Extracted from errSymLib.c
* $Log$
* Revision 1.7 1995/11/08 23:44:41 jhill
* changes associated with fixing the log client
*
***************************************************************************
*/
@@ -126,8 +129,8 @@ void errPrintf(long status, const char *pFileName,
va_list pvar;
if(INT_CONTEXT()) {
int logMsgArgs[6];
int i;
int logMsgArgs[6];
unsigned i;
va_start (pvar, pformat);
for (i=0; i<NELEMENTS(logMsgArgs); i++) {
@@ -210,8 +213,8 @@ int epicsVprintf(const char *pformat, va_list pvar)
int status;
if(INT_CONTEXT()) {
int logMsgArgs[6];
int i;
int logMsgArgs[6];
unsigned i;
for (i=0; i<NELEMENTS(logMsgArgs); i++) {
logMsgArgs[i] = va_arg(pvar, int);

View File

@@ -86,10 +86,15 @@
extern SYMTAB_ID statSymTbl;
#else
#ifndef _NTSDK
/* MS Visual C has defines for these in stdlib.h -kuk- */
extern int sys_nerr;
extern char *sys_errlist[];
#endif
#endif
#ifdef vxWorks
#define MYERRNO (errnoGet()&0xffff)

View File

@@ -86,10 +86,15 @@
extern SYMTAB_ID statSymTbl;
#else
#ifndef _NTSDK
/* MS Visual C has defines for these in stdlib.h -kuk- */
extern int sys_nerr;
extern char *sys_errlist[];
#endif
#endif
#ifdef vxWorks
#define MYERRNO (errnoGet()&0xffff)

View File

@@ -4,6 +4,9 @@
//
//
// $Log$
// Revision 1.1 1996/08/13 22:48:23 jhill
// dfMgr =>fdManager
//
//
//
@@ -44,12 +47,20 @@ inline int selectErrno()
//
fdManager::fdManager()
{
FD_ZERO (&this->read);
FD_ZERO (&this->write);
FD_ZERO (&this->exception);
size_t i;
for (i=0u; i<sizeof(this->fdSets)/sizeof(this->fdSets[0u]); i++) {
FD_ZERO(&this->fdSets[i]);
}
this->maxFD = 0;
this->processInProg = 0;
this->processInProg = 0u;
this->pCBReg = 0;
//
// should throw an exception here
// when most compilers are implementing
// exceptions
//
assert (this->fdTbl.init(0x100)>=0);
}
//
@@ -90,7 +101,7 @@ void fdManager::process (const osiTime &delay)
this->processInProg = 1;
while ( (pReg=regIter()) ) {
FD_SET(pReg->fd, &pReg->fdSet);
FD_SET(pReg->getFD(), &this->fdSets[pReg->getType()]);
}
//
@@ -111,8 +122,8 @@ void fdManager::process (const osiTime &delay)
minDelay = delay;
}
minDelay.getTV (tv.tv_sec, tv.tv_usec);
status = select (this->maxFD, &this->read,
&this->write, &this->exception, &tv);
status = select (this->maxFD, &this->fdSets[fdrRead],
&this->fdSets[fdrWrite], &this->fdSets[fdrExcp], &tv);
staticTimerQueue.process();
if (status==0) {
this->processInProg = 0;
@@ -135,8 +146,8 @@ void fdManager::process (const osiTime &delay)
//
regIter.reset();
while ( (pReg=regIter()) ) {
if (FD_ISSET(pReg->fd, &pReg->fdSet)) {
FD_CLR(pReg->fd, &pReg->fdSet);
if (FD_ISSET(pReg->getFD(), &this->fdSets[pReg->getType()])) {
FD_CLR(pReg->getFD(), &this->fdSets[pReg->getType()]);
regIter.remove();
this->activeList.add(*pReg);
pReg->state = fdrActive;
@@ -201,10 +212,22 @@ void fdReg::show(unsigned level)
{
printf ("fdReg at %x\n", (unsigned) this);
if (level>1u) {
printf ("\tfd = %d, fdSet at %x, state = %d, onceOnly = %d\n",
this->fd, (unsigned)&this->fdSet,
printf ("\tstate = %d, onceOnly = %d\n",
this->state, this->onceOnly);
}
this->fdRegId::show(level);
}
//
// fdRegId::show()
//
void fdRegId::show(unsigned level)
{
printf ("fdRegId at %x\n", (unsigned) this);
if (level>1u) {
printf ("\tfd = %d, type = %d\n",
this->fd, this->type);
}
}

View File

@@ -32,6 +32,9 @@
*
* History
* $Log$
* Revision 1.1 1996/08/13 22:48:21 jhill
* dfMgr =>fdManager
*
*
*/
@@ -39,6 +42,7 @@
#define fdManagerH_included
#include <tsDLList.h>
#include <resourceLib.h>
#include <osiTime.h>
#ifdef WIN32
@@ -52,14 +56,62 @@ extern "C" {
#include <stdio.h>
enum fdRegType {fdrRead, fdrWrite, fdrExcp};
enum fdRegType {fdrRead, fdrWrite, fdrExcp, fdRegTypeNElem};
enum fdRegState {fdrActive, fdrPending, fdrLimbo};
class fdRegId
{
public:
fdRegId (const int fdIn, const fdRegType typeIn) :
fd(fdIn), type(typeIn) {}
int getFD()
{
return this->fd;
}
fdRegType getType()
{
return this->type;
}
int operator == (const fdRegId &idIn)
{
return this->fd == idIn.fd && this->type==idIn.type;
}
resTableIndex resourceHash(unsigned nBitsId) const
{
unsigned src = (unsigned) this->fd;
resTableIndex hashid;
hashid = src;
src = src >> nBitsId;
while (src) {
hashid = hashid ^ src;
src = src >> nBitsId;
}
hashid = hashid ^ this->type;
//
// the result here is always masked to the
// proper size after it is returned to the resource class
//
return hashid;
}
virtual void show(unsigned level);
private:
const int fd;
const fdRegType type;
};
//
// fdReg
// file descriptor registration
//
class fdReg : public tsDLNode<fdReg> {
class fdReg : public tsDLNode<fdReg>, public fdRegId,
public tsSLNode<fdReg> {
friend class fdManager;
public:
fdReg (const int fdIn, const fdRegType typ,
@@ -89,8 +141,6 @@ private:
//
virtual void destroy ();
const int fd;
fd_set &fdSet;
unsigned char state; // fdRegState goes here
unsigned char onceOnly;
};
@@ -101,12 +151,15 @@ public:
fdManager();
~fdManager();
void process (const osiTime &delay);
//
// returns NULL if the fd is unknown
//
fdReg *lookUpFD(const int fd, const fdRegType type);
private:
tsDLList<fdReg> regList;
tsDLList<fdReg> activeList;
fd_set read;
fd_set write;
fd_set exception;
fd_set fdSets[fdRegTypeNElem];
int maxFD;
unsigned processInProg;
//
@@ -117,11 +170,22 @@ private:
void installReg (fdReg &reg);
void removeReg (fdReg &reg);
fd_set *pFDSet (fdRegType typIn);
resTable<fdReg,fdRegId> fdTbl;
};
extern fdManager fileDescriptorManager;
//
// lookUpFD()
//
inline fdReg *fdManager::lookUpFD(const int fd, const fdRegType type)
{
if (fd<0) {
return NULL;
}
fdRegId id (fd,type);
return this->fdTbl.lookup(id);
}
//
// fdManagerMaxInt ()
@@ -136,37 +200,23 @@ inline int fdManagerMaxInt (int a, int b)
}
}
//
// fdManager::pFDSet()
//
inline fd_set *fdManager::pFDSet (fdRegType typIn)
{
fd_set *pSet;
switch (typIn) {
case fdrRead:
pSet = &this->read;
break;
case fdrWrite:
pSet = &this->write;
break;
case fdrExcp:
pSet = &this->exception;
break;
default:
assert(0);
}
return pSet;
}
//
// fdManager::installReg()
//
inline void fdManager::installReg (fdReg &reg)
{
this->maxFD = fdManagerMaxInt(this->maxFD, reg.fd+1);
int status;
this->maxFD = fdManagerMaxInt(this->maxFD, reg.getFD()+1);
this->regList.add(reg);
reg.state = fdrPending;
status = this->fdTbl.add(reg);
if (status) {
fprintf (stderr,
"**** Warning - duplicate fdReg object\n");
fprintf (stderr,
"**** will not be seen by fdManager::lookUpFD()\n");
}
}
//
@@ -174,6 +224,8 @@ inline void fdManager::installReg (fdReg &reg)
//
inline void fdManager::removeReg(fdReg &reg)
{
fdReg *pItemFound;
//
// signal fdManager that the fdReg was deleted
// during the call back
@@ -181,21 +233,22 @@ inline void fdManager::removeReg(fdReg &reg)
if (this->pCBReg == &reg) {
this->pCBReg = 0;
}
FD_CLR(reg.fd, &reg.fdSet);
FD_CLR(reg.getFD(), &this->fdSets[reg.getType()]);
pItemFound = this->fdTbl.remove(reg);
assert (pItemFound==&reg);
switch (reg.state) {
case fdrActive:
this->activeList.remove(reg);
reg.state = fdrLimbo;
break;
case fdrPending:
this->regList.remove(reg);
reg.state = fdrLimbo;
break;
case fdrLimbo:
break;
default:
assert(0);
}
reg.state = fdrLimbo;
}
//
@@ -203,11 +256,10 @@ inline void fdManager::removeReg(fdReg &reg)
//
inline fdReg::fdReg (const int fdIn, const fdRegType typIn,
const unsigned onceOnlyIn) :
fd(fdIn), fdSet(*fileDescriptorManager.pFDSet(typIn)),
state(fdrLimbo), onceOnly(onceOnlyIn)
fdRegId(fdIn,typIn), state(fdrLimbo), onceOnly(onceOnlyIn)
{
assert (this->fd>=0);
if (this->fd>FD_SETSIZE) {
assert (fdIn>=0);
if (fdIn>FD_SETSIZE) {
fprintf (stderr, "%s: fd > FD_SETSIZE ignored\n",
__FILE__);
return;

View File

@@ -4,6 +4,9 @@
//
//
// $Log$
// Revision 1.1 1996/08/13 22:48:23 jhill
// dfMgr =>fdManager
//
//
//
@@ -44,12 +47,20 @@ inline int selectErrno()
//
fdManager::fdManager()
{
FD_ZERO (&this->read);
FD_ZERO (&this->write);
FD_ZERO (&this->exception);
size_t i;
for (i=0u; i<sizeof(this->fdSets)/sizeof(this->fdSets[0u]); i++) {
FD_ZERO(&this->fdSets[i]);
}
this->maxFD = 0;
this->processInProg = 0;
this->processInProg = 0u;
this->pCBReg = 0;
//
// should throw an exception here
// when most compilers are implementing
// exceptions
//
assert (this->fdTbl.init(0x100)>=0);
}
//
@@ -90,7 +101,7 @@ void fdManager::process (const osiTime &delay)
this->processInProg = 1;
while ( (pReg=regIter()) ) {
FD_SET(pReg->fd, &pReg->fdSet);
FD_SET(pReg->getFD(), &this->fdSets[pReg->getType()]);
}
//
@@ -111,8 +122,8 @@ void fdManager::process (const osiTime &delay)
minDelay = delay;
}
minDelay.getTV (tv.tv_sec, tv.tv_usec);
status = select (this->maxFD, &this->read,
&this->write, &this->exception, &tv);
status = select (this->maxFD, &this->fdSets[fdrRead],
&this->fdSets[fdrWrite], &this->fdSets[fdrExcp], &tv);
staticTimerQueue.process();
if (status==0) {
this->processInProg = 0;
@@ -135,8 +146,8 @@ void fdManager::process (const osiTime &delay)
//
regIter.reset();
while ( (pReg=regIter()) ) {
if (FD_ISSET(pReg->fd, &pReg->fdSet)) {
FD_CLR(pReg->fd, &pReg->fdSet);
if (FD_ISSET(pReg->getFD(), &this->fdSets[pReg->getType()])) {
FD_CLR(pReg->getFD(), &this->fdSets[pReg->getType()]);
regIter.remove();
this->activeList.add(*pReg);
pReg->state = fdrActive;
@@ -201,10 +212,22 @@ void fdReg::show(unsigned level)
{
printf ("fdReg at %x\n", (unsigned) this);
if (level>1u) {
printf ("\tfd = %d, fdSet at %x, state = %d, onceOnly = %d\n",
this->fd, (unsigned)&this->fdSet,
printf ("\tstate = %d, onceOnly = %d\n",
this->state, this->onceOnly);
}
this->fdRegId::show(level);
}
//
// fdRegId::show()
//
void fdRegId::show(unsigned level)
{
printf ("fdRegId at %x\n", (unsigned) this);
if (level>1u) {
printf ("\tfd = %d, type = %d\n",
this->fd, this->type);
}
}

View File

@@ -32,6 +32,9 @@
*
* History
* $Log$
* Revision 1.1 1996/08/13 22:48:21 jhill
* dfMgr =>fdManager
*
*
*/
@@ -39,6 +42,7 @@
#define fdManagerH_included
#include <tsDLList.h>
#include <resourceLib.h>
#include <osiTime.h>
#ifdef WIN32
@@ -52,14 +56,62 @@ extern "C" {
#include <stdio.h>
enum fdRegType {fdrRead, fdrWrite, fdrExcp};
enum fdRegType {fdrRead, fdrWrite, fdrExcp, fdRegTypeNElem};
enum fdRegState {fdrActive, fdrPending, fdrLimbo};
class fdRegId
{
public:
fdRegId (const int fdIn, const fdRegType typeIn) :
fd(fdIn), type(typeIn) {}
int getFD()
{
return this->fd;
}
fdRegType getType()
{
return this->type;
}
int operator == (const fdRegId &idIn)
{
return this->fd == idIn.fd && this->type==idIn.type;
}
resTableIndex resourceHash(unsigned nBitsId) const
{
unsigned src = (unsigned) this->fd;
resTableIndex hashid;
hashid = src;
src = src >> nBitsId;
while (src) {
hashid = hashid ^ src;
src = src >> nBitsId;
}
hashid = hashid ^ this->type;
//
// the result here is always masked to the
// proper size after it is returned to the resource class
//
return hashid;
}
virtual void show(unsigned level);
private:
const int fd;
const fdRegType type;
};
//
// fdReg
// file descriptor registration
//
class fdReg : public tsDLNode<fdReg> {
class fdReg : public tsDLNode<fdReg>, public fdRegId,
public tsSLNode<fdReg> {
friend class fdManager;
public:
fdReg (const int fdIn, const fdRegType typ,
@@ -89,8 +141,6 @@ private:
//
virtual void destroy ();
const int fd;
fd_set &fdSet;
unsigned char state; // fdRegState goes here
unsigned char onceOnly;
};
@@ -101,12 +151,15 @@ public:
fdManager();
~fdManager();
void process (const osiTime &delay);
//
// returns NULL if the fd is unknown
//
fdReg *lookUpFD(const int fd, const fdRegType type);
private:
tsDLList<fdReg> regList;
tsDLList<fdReg> activeList;
fd_set read;
fd_set write;
fd_set exception;
fd_set fdSets[fdRegTypeNElem];
int maxFD;
unsigned processInProg;
//
@@ -117,11 +170,22 @@ private:
void installReg (fdReg &reg);
void removeReg (fdReg &reg);
fd_set *pFDSet (fdRegType typIn);
resTable<fdReg,fdRegId> fdTbl;
};
extern fdManager fileDescriptorManager;
//
// lookUpFD()
//
inline fdReg *fdManager::lookUpFD(const int fd, const fdRegType type)
{
if (fd<0) {
return NULL;
}
fdRegId id (fd,type);
return this->fdTbl.lookup(id);
}
//
// fdManagerMaxInt ()
@@ -136,37 +200,23 @@ inline int fdManagerMaxInt (int a, int b)
}
}
//
// fdManager::pFDSet()
//
inline fd_set *fdManager::pFDSet (fdRegType typIn)
{
fd_set *pSet;
switch (typIn) {
case fdrRead:
pSet = &this->read;
break;
case fdrWrite:
pSet = &this->write;
break;
case fdrExcp:
pSet = &this->exception;
break;
default:
assert(0);
}
return pSet;
}
//
// fdManager::installReg()
//
inline void fdManager::installReg (fdReg &reg)
{
this->maxFD = fdManagerMaxInt(this->maxFD, reg.fd+1);
int status;
this->maxFD = fdManagerMaxInt(this->maxFD, reg.getFD()+1);
this->regList.add(reg);
reg.state = fdrPending;
status = this->fdTbl.add(reg);
if (status) {
fprintf (stderr,
"**** Warning - duplicate fdReg object\n");
fprintf (stderr,
"**** will not be seen by fdManager::lookUpFD()\n");
}
}
//
@@ -174,6 +224,8 @@ inline void fdManager::installReg (fdReg &reg)
//
inline void fdManager::removeReg(fdReg &reg)
{
fdReg *pItemFound;
//
// signal fdManager that the fdReg was deleted
// during the call back
@@ -181,21 +233,22 @@ inline void fdManager::removeReg(fdReg &reg)
if (this->pCBReg == &reg) {
this->pCBReg = 0;
}
FD_CLR(reg.fd, &reg.fdSet);
FD_CLR(reg.getFD(), &this->fdSets[reg.getType()]);
pItemFound = this->fdTbl.remove(reg);
assert (pItemFound==&reg);
switch (reg.state) {
case fdrActive:
this->activeList.remove(reg);
reg.state = fdrLimbo;
break;
case fdrPending:
this->regList.remove(reg);
reg.state = fdrLimbo;
break;
case fdrLimbo:
break;
default:
assert(0);
}
reg.state = fdrLimbo;
}
//
@@ -203,11 +256,10 @@ inline void fdManager::removeReg(fdReg &reg)
//
inline fdReg::fdReg (const int fdIn, const fdRegType typIn,
const unsigned onceOnlyIn) :
fd(fdIn), fdSet(*fileDescriptorManager.pFDSet(typIn)),
state(fdrLimbo), onceOnly(onceOnlyIn)
fdRegId(fdIn,typIn), state(fdrLimbo), onceOnly(onceOnlyIn)
{
assert (this->fd>=0);
if (this->fd>FD_SETSIZE) {
assert (fdIn>=0);
if (fdIn>FD_SETSIZE) {
fprintf (stderr, "%s: fd > FD_SETSIZE ignored\n",
__FILE__);
return;

View File

@@ -0,0 +1,28 @@
/*
* Solaris specifif socket include
*/
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <sys/filio.h>
#include <sys/sockio.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#ifdef __cplusplus
}
#endif
typedef int SOCKET;
#define SOCKERRNO errno
#define socket_close(S) close(S)
#define socket_ioctl(A,B,C) ioctl(A,B,C)

View File

@@ -0,0 +1,80 @@
/*
* sun4 specific socket include
*/
#ifndef SUNOS4
#errro this is a SUNOS4 specific socket include
#endif
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
int ioctl (int fd, int req, ...);
int close (int fd);
int gettimeofday (struct timeval *tp, struct timezone *tzp);
int gethostname (char *name, int namelen);
/*
* sun's CC defines at least a few of these under sunos4
*/
#if defined(__SUNPRO_CC)
# include <arpa/inet.h>
#else
int listen (int socket, int backlog);
int accept (int socket, struct sockaddr *addr, int *addrlen);
int shutdown (int socket, int how);
int getpeername (int socket, struct sockaddr *name, int *namelen);
int connect (int socket, struct sockaddr *name, int namelen);
int setsockopt (int socket, int level, int optname,
char *optval, int optlen);
void bzero (char *b, int length);
int sendto (int socket, const char *buf, int len,
int flags, struct sockaddr *to, int tolen);
int select (int width, fd_set *readfds, fd_set *writefds,
fd_set *exceptfds, struct timeval *timeout);
int bind (int socket, struct sockaddr *name, int namelen);
int send (int socket, const char *buf, int len, int flags);
int recv (int socket, char *buf, int len, int flags);
int getsockopt (int socket, int level, int optname,
char *optval, int *optlen);
int socket (int domain, int type, int protocol);
int recvfrom (int socket, char *buf, int len,
int flags, struct sockaddr *from, int *fromlen);
int getsockname (int socket, struct sockaddr *name, int *namelen);
/*
* from /usr/include/arpa/inet.h
* (which under sunos4 does not include arguments for C++)
* (__SUNPRO_CC supplies this file but g++ does not supply an ansi protottype)
*/
unsigned long inet_addr (char *);
char * inet_ntoa (struct in_addr in);
/*
* from /usr/include/netdb.h
* (which under sunos4 does not include arguments for C++)
* (__SUNPRO_CC supplies this file but g++ does not)
*/
struct hostent *gethostbyaddr(char *addr, int len, int type);
#endif /* !defined(__SUNPRO_CC) */
#ifdef __cplusplus
}
#endif
typedef int SOCKET;
#define SOCKERRNO errno
#define socket_close(S) close(S)
#define socket_ioctl(A,B,C) ioctl(A,B,C)

Some files were not shown because too many files have changed in this diff Show More