synchronize API with library.h, zero struct on allocation, determine exception support at runtime.
This commit is contained in:
@ -56,7 +56,8 @@ liblammpsplugin_t *liblammpsplugin_load(const char *lib)
|
||||
#endif
|
||||
if (handle == NULL) return NULL;
|
||||
|
||||
lmp = (liblammpsplugin_t *) malloc(sizeof(liblammpsplugin_t));
|
||||
lmp = (liblammpsplugin_t *) calloc(1, sizeof(liblammpsplugin_t));
|
||||
lmp->abiversion = LAMMPSPLUGIN_ABI_VERSION;
|
||||
lmp->handle = handle;
|
||||
|
||||
#ifdef _WIN32
|
||||
@ -179,15 +180,11 @@ liblammpsplugin_t *liblammpsplugin_load(const char *lib)
|
||||
ADDSYM(is_running);
|
||||
ADDSYM(force_timeout);
|
||||
|
||||
#ifdef LAMMPS_EXCEPTIONS
|
||||
lmp->has_exceptions = 1;
|
||||
ADDSYM(has_error);
|
||||
ADDSYM(get_last_error_message);
|
||||
#else
|
||||
lmp->has_exceptions = 0;
|
||||
lmp->has_error = NULL;
|
||||
lmp->get_last_error_message = NULL;
|
||||
#endif
|
||||
lmp->has_exceptions = lmp->config_has_exceptions();
|
||||
if (lmp->has_exceptions) {
|
||||
ADDSYM(has_error);
|
||||
ADDSYM(get_last_error_message);
|
||||
}
|
||||
|
||||
ADDSYM(python_api_version);
|
||||
return lmp;
|
||||
|
||||
@ -105,6 +105,7 @@ typedef void (*FixExternalFnPtr)(void *, int, int, int *, double **, double **);
|
||||
typedef void (*FixExternalFnPtr)(void *, int64_t, int, int *, double **, double **);
|
||||
#endif
|
||||
|
||||
#define LAMMPSPLUGIN_ABI_VERSION 1
|
||||
struct _liblammpsplugin {
|
||||
int abiversion;
|
||||
int has_exceptions;
|
||||
@ -153,19 +154,19 @@ struct _liblammpsplugin {
|
||||
int (*extract_variable_datatype)(void *, const char *);
|
||||
int (*set_variable)(void *, char *, char *);
|
||||
|
||||
void (*gather_atoms)(void *, char *, int, int, void *);
|
||||
void (*gather_atoms_concat)(void *, char *, int, int, void *);
|
||||
void (*gather_atoms_subset)(void *, char *, int, int, int, int *, void *);
|
||||
void (*scatter_atoms)(void *, char *, int, int, void *);
|
||||
void (*scatter_atoms_subset)(void *, char *, int, int, int, int *, void *);
|
||||
void (*gather_atoms)(void *, const char *, int, int, void *);
|
||||
void (*gather_atoms_concat)(void *, const char *, int, int, void *);
|
||||
void (*gather_atoms_subset)(void *, const char *, int, int, int, int *, void *);
|
||||
void (*scatter_atoms)(void *, const char *, int, int, void *);
|
||||
void (*scatter_atoms_subset)(void *, const char *, int, int, int, int *, void *);
|
||||
|
||||
void (*gather_bonds)(void *, void *);
|
||||
|
||||
void (*gather)(void *, char *, int, int, void *);
|
||||
void (*gather_concat)(void *, char *, int, int, void *);
|
||||
void (*gather_subset)(void *, char *, int, int, int, int *,void *);
|
||||
void (*scatter)(void *, char *, int, int, void *);
|
||||
void (*scatter_subset)(void *, char *, int, int, int, int *, void *);
|
||||
void (*gather)(void *, const char *, int, int, void *);
|
||||
void (*gather_concat)(void *, const char *, int, int, void *);
|
||||
void (*gather_subset)(void *, const char *, int, int, int, int *,void *);
|
||||
void (*scatter)(void *, const char *, int, int, void *);
|
||||
void (*scatter_subset)(void *, const char *, int, int, int, int *, void *);
|
||||
|
||||
/* lammps_create_atoms() takes tagint and imageint as args
|
||||
* the ifdef insures they are compatible with rest of LAMMPS
|
||||
|
||||
@ -92,6 +92,12 @@ int main(int narg, char **arg)
|
||||
if (me == 0) printf("ERROR: Could not load shared LAMMPS library\n");
|
||||
MPI_Abort(MPI_COMM_WORLD,1);
|
||||
}
|
||||
/* must match the plugin ABI version */
|
||||
if (plugin->abiversion != LAMMPSPLUGIN_ABI_VERSION) {
|
||||
if (me == 0) printf("ERROR: Plugin abi version does not match: %d vs %d\n",
|
||||
plugin->abiversion, LAMMPSPLUGIN_ABI_VERSION);
|
||||
MPI_Abort(MPI_COMM_WORLD,1);
|
||||
}
|
||||
}
|
||||
if (lammps == 1) {
|
||||
if (plugin->open == NULL) {
|
||||
|
||||
Reference in New Issue
Block a user