Skip to content

Commit

Permalink
hds: Wrap the v4 and v5 libraries
Browse files Browse the repository at this point in the history
libhds is now a wrapper library that selects the v4 or v5 API
based on the type of locator. The current implementation of the
wrapper is mostly complete but lacks support for copying between
different HDS versions and true support of cases where the API
can not tell which version to use so must try both.

hds_select.c has been modified from the automatically generated
version so do not attempt to regenerate.

HDS still has the Fortran wrapper library which links to libhds.
Most of the changes in the Fortran code involve removal of low
level HDS header files (e.g. rec.h and str.h) and switching to
use SAE for good status rathder than the (historical) private
value of DAT__OK.

HDS now depends on ONE and SAE.
  • Loading branch information
timj committed Oct 31, 2014
1 parent 44db81d commit 4a29b0d
Show file tree
Hide file tree
Showing 19 changed files with 2,153 additions and 247 deletions.
1 change: 0 additions & 1 deletion libraries/hds/.gitignore
@@ -1,5 +1,4 @@
/DAT_PAR
/dat_par.h
/dat_par_f
/dat_par_h
/hds1_types.h
Expand Down
95 changes: 11 additions & 84 deletions libraries/hds/Makefile.am
@@ -1,15 +1,13 @@
## Process this file with automake to produce Makefile.in

bin_PROGRAMS = hdsdump
dist_bin_SCRIPTS = hds_link hds_link_adam
noinst_PROGRAMS = hds_machine dat_par_h dat_par_f make-hds-types
starhelp_DATA = hds_machine.txt
noinst_PROGRAMS = dat_par_f make-hds-types

# libhdsf is for fortran interface
lib_LTLIBRARIES = libhds.la libhdsf.la

TESTS = hds_test hdsTest hds_test_prm
check_PROGRAMS = hds_test hdsTest hds_test_prm
TESTS = hds_test hdsTest
check_PROGRAMS = hds_test hdsTest

libhds_la_SOURCES = \
$(PUBLIC_INCLUDES) \
Expand All @@ -18,14 +16,14 @@ libhds_la_SOURCES = \
$(PRIVATE_INCLUDES) \
$(C_ROUTINES)

libhds_la_LIBADD = `starmem_link` `ems_link`
libhds_la_LIBADD = -lhds_v4 -lhds_v5

libhdsf_la_SOURCES = \
$(F_ROUTINES) \
$(F_C_ROUTINES) \
$(BLOCK_DATA_FILES)

libhdsf_la_LIBADD = `ems_link` `one_link`
libhdsf_la_LIBADD = libhds.la `ems_link` `one_link` `chr_link`

# Make all library code position independent. This is handy for creating
# shareable libraries from the static ones (Java JNI libraries).
Expand All @@ -36,29 +34,18 @@ libhdsf_la_CFLAGS = $(AM_CFLAGS) -prefer-pic
libhdsf_la_FCFLAGS = $(AM_FCFLAGS) -prefer-pic
endif

hds_machine_SOURCES = hds_machine.c
hds_machine_LDADD = libhds.la `ems_link` `cnf_link` `starmem_link`

dat_par_h_SOURCES = dat_par_h.c
dat_par_f_SOURCES = dat_par_f.c
make_hds_types_SOURCES = make-hds-types.c

hdsdump_SOURCES = hds_dev/hdsdump.c
hdsdump_LDADD = libhds.la `ems_link` `cnf_link` `starmem_link`

# Try to make sure that hds_types.h is built early
# This does not seem to work right in conjunction with BUILT_SOURCES
dat_par_h_DEPENDENCIES = hds_types.h hds1_types.h
dat_par_f_DEPENDENCIES = hds_types.h hds1_types.h
dat_par_f_DEPENDENCIES = hds_types.h hds1_types.h dat_par.h

hds_test_SOURCES = hds_test.f
hds_test_LDADD = libhdsf.la libhds.la `ems_link` `chr_link` `cnf_link`
hds_test_LDADD = libhdsf.la

hdsTest_SOURCES = hdsTest.c
hdsTest_LDADD = libhds.la `ems_link` `cnf_link` `cnf_link`

hds_test_prm_SOURCES = hds_test_prm.c
hds_test_prm_LDADD = libhds.la `ems_link` `cnf_link` `cnf_link`
hdsTest_LDADD = libhds.la

cincludedir = $(includedir)/star
cinclude_HEADERS = $(PUBLIC_CINCLUDES)
Expand All @@ -72,10 +59,7 @@ PUBLIC_CINCLUDES = hds.h hds_types.h hds_fortran.h
PUBLIC_INCLUDES = DAT_PAR dat_par.h

PRIVATE_INCLUDES = \
CMP_CCT CMP_CONST DAT1_SYS \
dat1.h hds1.h hds2.h hds1_types.h \
rec.h rec1.h str.h \
win_fixups.h \
CMP_CCT CMP_CONST DAT1_SYS dat1.h \
$(noinst_MESSAGES)

F_ROUTINES = \
Expand All @@ -95,60 +79,8 @@ F_C_ROUTINES = hds_run.c fortran_interface.c hdsFind.c
BLOCK_DATA_FILES = cmp_blk.f

C_ROUTINES = \
dat1_alloc_lcp.c dat1_annul_lcp.c dat1_check_mode.c \
dat1_check_type.c dat1_cvt_format.c dat1_cvt_order.c \
dat1_decoy.c dat1_get_ncomp.c dat1_get_odl.c dat1_getenv.c \
dat1_import_loc.c dat1_init.c dat1_init_ndr.c dat1_intune.c \
dat1_locate_name.c dat1_pack_crv.c dat1_pack_odl.c \
dat1_pack_srv.c dat1_put_ncomp.c dat1_put_odl.c \
dat1_show_ndr.c dat1_unpack_crv.c dat1_unpack_odl.c \
dat1_unpack_srv.c dat1_unpack_type.c \
dat1_free_hdsloc.c dat1_import_floc.c \
datClen.c datCopy.c datMsg.c datRef.c \
datDrep.c datErmsg.c datParen.c datPrec.c datPrmry.c datRefct.c \
datWhere.c datalter.c datannul.c datccopy.c daterase.c datfinind.c \
datget.c datget0x.c datinq.c datlocops.c datmap.c datmove.c datnew.c \
datnew0.c datMapN.c datPut1C.c datPutVC.c datGet1C.c datGetVC.c \
datChscn.c \
datput.c datput0x.c dattemp.c daucheck.c daucnv.c daucopy.c \
dauflush.c \
dauloc.c daumove.c dauscatgath.c daushape.c dautypes.c \
datExportFloc.c datImportFloc.c hdsdim.c hds1_cleanup.c \
hds1_exit.c hdsCopy.c hdsEwild.c hds_globals.c hdsGtune.c \
hdsState.c hdsStop.c hdsTune.c \
hdsWild.c hdserase.c hdsgroup.c hdslock.c hdsnew.c hdsnull.c \
hdsopclos.c hdstools.c hdsInfoI.c \
dat1emsSetBigi.c dat1emsSetBigu.c dat1emsSetHdsdim.c \
rec1_alloc_frame.c rec1_clear_cbm.c rec1_close_file.c \
rec1_close_slot.c rec1_create_file.c rec1_deall_frame.c \
rec1_extend_file.c rec1_extend_frame.c rec1_find_file.c \
rec1_flush_block.c rec1_fmsg.c rec1_get_fid.c rec1_get_path.c \
rec1_getcwd.c rec1_locate_hcb.c rec1_lock_slot.c \
rec1_map_frame.c rec1_open_file.c rec1_pack_chain.c \
rec1_pack_hcb.c rec1_pack_ncomp.c rec1_pack_rcl.c \
rec1_read_file.c rec1_save_addr.c rec1_scan_cbm.c \
rec1_set_cbm.c rec1_shell.c rec1_test_cbm.c rec1_unlock_slot.c \
rec1_unmap_frame.c rec1_unpack_chain.c rec1_unpack_hcb.c \
rec1_unpack_ncomp.c rec1_unpack_rcl.c rec1_update_free.c \
rec1_write_file.c \
\
rec_adopt_record.c rec_alloc_mem.c rec_alloc_xmem.c \
rec_attach_file.c rec_close_file.c rec_create_record.c \
rec_count_files.c \
rec_deall_mem.c rec_deall_xmem.c rec_delete_record.c \
rec_end_wild.c rec_extend_record.c rec_get_handle.c \
rec_get_rcl.c rec_get_rid.c rec_list_files.c \
rec_locate_block.c rec_locate_data.c rec_locate_fns.c \
rec_lock.c rec_mark_delete.c rec_reall_mem.c rec_refcnt.c \
rec_release_block.c rec_release_data.c rec_reset_record.c \
rec_same_file.c rec_shrink_record.c rec_start.c rec_stop.c \
rec_unlock.c rec_where.c rec_wild_file.c \
rtl_fixups.c \
win_fixups.c \
hds_start.c

dat_par.h: dat_par_h$(EXEEXT)
./dat_par_h >dat_par.h
datExportFloc.c datImportFloc.c dat1_import_floc.c hdsdim.c \
hds_select.c

DAT_PAR: dat_par_f$(EXEEXT)
./dat_par_f > DAT_PAR
Expand All @@ -159,11 +91,6 @@ hds_types.h: make-hds-types$(EXEEXT)
hds1_types.h: make-hds-types$(EXEEXT)
./make-hds-types

hds_machine.txt: hds_machine$(EXEEXT)
echo "Machine characteristics, as determined by HDS" >$@
echo "" >>$@
./hds_machine >>$@

# Have to make sure that hds_types appears before DAT_PAR so that
# the include file generation routines are built in the correct order
BUILT_SOURCES = hds_types.h hds1_types.h \
Expand Down
4 changes: 2 additions & 2 deletions libraries/hds/component.xml
Expand Up @@ -3,7 +3,7 @@
<!-- component.xml. Generated from component.xml.in by configure. -->

<component id="hds" support="S">
<version>5.1-1</version>
<version>6.0-1</version>
<path>libraries/hds</path>
<description>Hierarchical Data System</description>
<abstract>
Expand All @@ -28,7 +28,7 @@
software.</p>
</abstract>
<dependencies >
<build>sae</build><build>chr</build><build>cnf</build><build>ems</build><build>starmem</build><link>chr</link><link>cnf</link><link>ems</link><link>starmem</link><test>chr</test><test>cnf</test><test>ems</test><test>prm</test><test>starmem</test><sourceset>star2html</sourceset><sourceset>messgen</sourceset>
<build>sae</build><build>chr</build><build>cnf</build><build>ems</build><build>starmem</build><build>one</build><build>hds-v4</build><build>hds-v5</build><link>chr</link><link>cnf</link><link>ems</link><link>starmem</link><link>one</link><link>hds-v4</link><link>hds-v5</link><test>chr</test><test>cnf</test><test>ems</test><test>prm</test><test>starmem</test><test>one</test><test>hds-v4</test><test>hds-v5</test><sourceset>star2html</sourceset><sourceset>messgen</sourceset>
</dependencies>
<developers>
<person>
Expand Down
64 changes: 5 additions & 59 deletions libraries/hds/configure.ac
Expand Up @@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script
AC_REVISION($Revision$)

dnl Initialisation: package name and version number
AC_INIT([hds],[5.1-1],[starlink@jiscmail.ac.uk])
AC_INIT([hds],[6.0-1],[starlink@jiscmail.ac.uk])
AC_CONFIG_AUX_DIR([build-aux])

dnl Require autoconf-2.50 at least
Expand All @@ -12,20 +12,11 @@ AM_INIT_AUTOMAKE([1.8.2-starlink subdir-objects])

dnl Sanity-check: name a file in the source directory -- if this
dnl isn't found then configure will complain
AC_CONFIG_SRCDIR([hdsState.c])
AC_CONFIG_SRCDIR([hds_select.c])

dnl Include defaults for Starlink configurations
STAR_DEFAULTS

dnl Define _POSIX_C_SOURCE to be used in all routines. This was
dnl declared in the old header file "hds1_feature.h", but we need
dnl to make sure all feature-level defines are included in the autoconf
dnl tests (this is important for large file support under Solaris, which
dnl does not define _LARGEFILE_SOURCE without _POSIX_C_SOURCE).
AC_DEFINE([_POSIX_C_SOURCE], [200112L], [Specify the version of the POSIX
standard we want to work with (should provide POSIX.1, POSIX.2 and POSIX.4,
if available)])

dnl Find required versions of the programs we need for configuration
AC_PROG_CC
AC_PROG_FC
Expand All @@ -36,40 +27,8 @@ AM_CONDITIONAL(NOPIC, test x$pic_mode = xno)

AC_C_BIGENDIAN

dnl Check for OS features we would like
AC_FUNC_FORK

dnl The AC_FUNC_MMAP test is broken under Cygwin.
case "$host" in
*cygwin*)
AC_CHECK_FUNCS(mmap)
;;
*)
AC_FUNC_MMAP
;;
esac

STAR_CNF_COMPATIBLE_SYMBOLS

dnl MinGW doesn't have this one.
AC_CHECK_HEADERS(sys/wait.h)

dnl Used for dynamic header files
AC_CHECK_HEADERS( time.h )

dnl Or file locking.
AC_CHECK_FUNCS(fcntl)

dnl Or fsync
AC_CHECK_FUNCS(fsync)

dnl RTL "fixups"
AC_CHECK_FUNCS(atexit)
AC_CHECK_FUNCS(on_exit)
AC_CHECK_FUNCS(memmove)

AC_CHECK_FUNCS([getwd getcwd])

dnl Look for standard headers rather than assuming availability
dnl by operating system
AC_HEADER_STDC
Expand All @@ -78,19 +37,6 @@ AC_CHECK_HEADERS(unistd.h)
AC_CHECK_HEADERS([sys/param.h])
AC_CHECK_HEADERS(inttypes.h)

dnl Look for missing declarations
AC_CHECK_DECLS(confstr)
AC_CHECK_DECLS(getwd)

dnl fsync is only declared if _POSIX_C_SOURCE isn't!!
AC_CHECK_DECLS(fsync)

dnl On Darwin access to the _environ symbol is only available to
dnl the linker when building applications, so cannot be used reliably in
dnl shared libraries, so need to use the _NSGetEnviron() function.
AC_CHECK_HEADERS(crt_externs.h)
AC_CHECK_FUNCS(_NSGetEnviron)

dnl Check for largefile support (various macros and fseeko).
dnl Make sure we don't use the cached version for this (can
dnl be incorrect due to _POSIX_C_SOURCE on Solaris).
Expand All @@ -109,9 +55,9 @@ AC_CHECK_SIZEOF(off_t)
AC_CHECK_SIZEOF(size_t)

dnl Declare the build and use dependencies for this package
STAR_DECLARE_DEPENDENCIES([build], [sae chr cnf ems starmem])
STAR_DECLARE_DEPENDENCIES([link], [chr cnf ems starmem])
STAR_DECLARE_DEPENDENCIES([test], [chr cnf ems prm starmem])
STAR_DECLARE_DEPENDENCIES([build], [sae chr cnf ems starmem one hds-v4 hds-v5])
STAR_DECLARE_DEPENDENCIES([link], [chr cnf ems starmem one hds-v4 hds-v5])
STAR_DECLARE_DEPENDENCIES([test], [chr cnf ems prm starmem one hds-v4 hds-v5])

dnl List the sun/ssn/... numbers which document this package and
dnl which are present as .tex files in this directory.
Expand Down
70 changes: 70 additions & 0 deletions libraries/hds/dat1.h
@@ -0,0 +1,70 @@
/*
*+
* Name:
* dat1.h
* Purpose:
* Private header file for HDS wrapper
* Language:
* Starlink ANSI C
* Type of Module:
* C Header File
* Invocation:
* #include "dat1.h"
* Description:
* Private header file for the HDS wrapper library.
* Authors:
* TIMJ: Tim Jenness (Cornell)
* {enter_new_authors_here}
* History:
* 2014-10-28 (TIMJ):
* Initial version
* {enter_further_changes_here}
* Copyright:
* Copyright (C) 2014 Cornell University
* All Rights Reserved.
* Licence:
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 3 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* Bugs:
* {note_any_bugs_here}
*-
*/

#if !defined( DAT_1_H_INCLUDED ) /* dat1.h already included? */
#define DAT_1_H_INCLUDED 1

#include "dat_par.h"

/* Wrapper definition of an HDS locator struct. The first element */
/* must be present in both v4 and v5 implementations. */
/* We can not use an opaque struct internally but we can also not */
/* use a full definition of the struct. Just enough for the */
/* compiler to be able to know how to read the version. */
#define HDS_USE_INTERNAL_STRUCT 1
typedef struct LOC { int hds_version; } HDSLoc;

HDSLoc *
dat1_import_floc ( const char flocator[DAT__SZLOC], int loc_length, int * status);

#endif

0 comments on commit 4a29b0d

Please sign in to comment.