Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Slurm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tud-zih-energy
Slurm
Commits
2b45dd54
Commit
2b45dd54
authored
22 years ago
by
jwindley
Browse files
Options
Downloads
Patches
Plain Diff
Add low-level plugin API.
parent
d62309fa
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/common/Makefile.am
+2
-0
2 additions, 0 deletions
src/common/Makefile.am
src/common/plugin.c
+106
-0
106 additions, 0 deletions
src/common/plugin.c
src/common/plugin.h
+119
-0
119 additions, 0 deletions
src/common/plugin.h
with
227 additions
and
0 deletions
src/common/Makefile.am
+
2
−
0
View file @
2b45dd54
...
@@ -35,6 +35,7 @@ libcommon_la_SOURCES = \
...
@@ -35,6 +35,7 @@ libcommon_la_SOURCES = \
pack.c
\
pack.c
\
hostlist.c
\
hostlist.c
\
parse_spec.c
\
parse_spec.c
\
plugin.c
\
read_config.c
\
read_config.c
\
slurm_errno.c
\
slurm_errno.c
\
slurm_protocol_api.c
\
slurm_protocol_api.c
\
...
@@ -63,6 +64,7 @@ noinst_HEADERS = \
...
@@ -63,6 +64,7 @@ noinst_HEADERS = \
pack.h
\
pack.h
\
hostlist.h
\
hostlist.h
\
parse_spec.h
\
parse_spec.h
\
plugin.h
\
read_config.h
\
read_config.h
\
slurm_auth.h
\
slurm_auth.h
\
slurm_protocol_api.h
\
slurm_protocol_api.h
\
...
...
This diff is collapsed.
Click to expand it.
src/common/plugin.c
0 → 100644
+
106
−
0
View file @
2b45dd54
/*****************************************************************************\
* plugin.h - plugin architecture implementation.
*****************************************************************************
* Copyright (C) 2002 The Regents of the University of California.
* Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
* Written by AUTHOR <AUTHOR@llnl.gov>.
* UCRL-CODE-2002-040.
*
* This file is part of SLURM, a resource management program.
* For details, see <http://www.llnl.gov/linux/slurm/>.
*
* SLURM 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 2 of the License, or (at your option)
* any later version.
*
* SLURM 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 SLURM; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
\*****************************************************************************/
#include
<sys/types.h>
#include
<stdio.h>
#include
<assert.h>
#include
<dlfcn.h>
#include
"src/common/plugin.h"
plugin_handle_t
plugin_load_from_file
(
const
char
*
fq_path
)
{
plugin_handle_t
plug
;
/* Try to open the shared object. */
plug
=
dlopen
(
fq_path
,
RTLD_LAZY
);
if
(
plug
==
NULL
)
{
return
NULL
;
}
/* Now see if our required symbols are defined. */
if
(
(
dlsym
(
plug
,
PLUGIN_NAME
)
==
NULL
)
||
(
dlsym
(
plug
,
PLUGIN_TYPE
)
==
NULL
)
||
(
dlsym
(
plug
,
PLUGIN_VERSION
)
==
NULL
)
)
{
return
NULL
;
}
return
plug
;
}
void
plugin_unload
(
plugin_handle_t
plug
)
{
assert
(
plug
);
(
void
)
dlclose
(
plug
);
}
void
*
plugin_get_sym
(
plugin_handle_t
plug
,
const
char
*
name
)
{
return
dlsym
(
plug
,
name
);
}
const
char
*
plugin_get_name
(
plugin_handle_t
plug
)
{
return
(
const
char
*
)
dlsym
(
plug
,
PLUGIN_NAME
);
}
const
char
*
plugin_get_type
(
plugin_handle_t
plug
)
{
return
(
const
char
*
)
dlsym
(
plug
,
PLUGIN_TYPE
);
}
uint32_t
plugin_get_version
(
plugin_handle_t
plug
)
{
uint32_t
*
ptr
=
(
uint32_t
*
)
dlsym
(
plug
,
PLUGIN_VERSION
);
return
ptr
?
*
ptr
:
0
;
}
int
plugin_get_syms
(
plugin_handle_t
plug
,
int
n_syms
,
const
char
*
names
[],
void
*
ptrs
[]
)
{
int
i
,
count
;
count
=
0
;
for
(
i
=
0
;
i
<
n_syms
;
++
i
)
{
ptrs
[
i
]
=
dlsym
(
plug
,
names
[
i
]
);
if
(
ptrs
[
i
]
)
++
count
;
}
return
count
;
}
This diff is collapsed.
Click to expand it.
src/common/plugin.h
0 → 100644
+
119
−
0
View file @
2b45dd54
/*****************************************************************************\
* plugin.h - plugin abstraction and operations.
*****************************************************************************
* Copyright (C) 2002 The Regents of the University of California.
* Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
* Written by AUTHOR <AUTHOR@llnl.gov>.
* UCRL-CODE-2002-040.
*
* This file is part of SLURM, a resource management program.
* For details, see <http://www.llnl.gov/linux/slurm/>.
*
* SLURM 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 2 of the License, or (at your option)
* any later version.
*
* SLURM 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 SLURM; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
\*****************************************************************************/
#ifndef __GENERIC_PLUGIN_H__
#define __GENERIC_PLUGIN_H__
#if HAVE_CONFIG_H
# include "config.h"
# if HAVE_INTTYPES_H
# include <inttypes.h>
# else
# if HAVE_STDINT_H
# include <stdint.h>
# endif
# endif
/* HAVE_INTTYPES_H */
#else
/* ! HAVE_CONFIG_H_ */
# include <inttypes.h>
#endif
/* HAVE_CONFIG_H */
#include
"src/common/slurm_errno.h"
/*
* These symbols are required to be defined in any plugin managed by
* this code. Use these macros instead of string literals in order to
* avoid typographical errors.
*
* Their meanings are described in the sample plugin.
*/
#define PLUGIN_NAME "plugin_name"
#define PLUGIN_TYPE "plugin_type"
#define PLUGIN_VERSION "plugin_version"
/*
* Opaque type for plugin handle. Most plugin operations will want
* of these.
*
* Currently there is no user-space memory associated with the plugin
* handle other than the pointer with which it is implemented. While
* allowing a handle to pass out of scope without explicit destruction
* will not leak user memory, it may leave the plugin loaded in memory.
*/
typedef
void
*
plugin_handle_t
;
#define PLUGIN_INVALID_HANDLE ((void*)0)
/*
* Simplest way to get a plugin -- load it from a file.
*
* fq_path - the fully-qualified pathname (i.e., from root) to
* the plugin to load.
*
* Returns a handle if successful, or NULL if not.
*
* The plugin's initialization code will be executed prior
* to this function's return.
*/
plugin_handle_t
plugin_load_from_file
(
const
char
*
fq_path
);
/*
* Unload a plugin from memory.
*/
void
plugin_unload
(
plugin_handle_t
plug
);
/*
* Get the address of a named symbol in the plugin.
*
* Returns the address of the symbol or NULL if not found.
*/
void
*
plugin_get_sym
(
plugin_handle_t
plug
,
const
char
*
name
);
/*
* Access functions to get the name, type, and version of a plugin
* from the plugin itself.
*/
const
char
*
plugin_get_name
(
plugin_handle_t
plug
);
const
char
*
plugin_get_type
(
plugin_handle_t
plug
);
uint32_t
plugin_get_version
(
plugin_handle_t
plug
);
/*
* Get the addresses of several symbols from the plugin at once.
*
* n_syms - the number of symbols in names[].
* names[] - an argv-like array of symbol names to resolve.
* ptrs[] - an array of pointers into which the addresses of the respective
* symbols should be placed. ptrs[i] will receive the address of
* names[i].
*
* Returns the number of symbols successfully resolved. Pointers whose
* associated symbol name was not found will be set to NULL.
*/
int
plugin_get_syms
(
plugin_handle_t
plug
,
int
n_syms
,
const
char
*
names
[],
void
*
ptrs
[]
);
#endif
/*__GENERIC_PLUGIN_H__*/
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment