1 /* Coordinate ELF library and application versions. 2 Copyright (C) 1998, 1999, 2000, 2002 Red Hat, Inc. 3 Contributed by Ulrich Drepper <drepper (at) redhat.com>, 1998. 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation, version 2. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License 15 along with this program; if not, write to the Free Software Foundation, 16 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 17 18 #ifdef HAVE_CONFIG_H 19 # include <config.h> 20 #endif 21 22 #include <libelfP.h> 23 24 25 /* Is the version initialized? */ 26 int __libelf_version_initialized; 27 28 /* Currently selected version. */ 29 unsigned int __libelf_version = EV_CURRENT; 30 31 32 unsigned int 33 elf_version (version) 34 unsigned int version; 35 { 36 if (version == EV_NONE) 37 return __libelf_version; 38 39 if (likely (version < EV_NUM)) 40 { 41 /* Phew, we know this version. */ 42 unsigned int last_version = __libelf_version; 43 44 /* Store the new version. */ 45 __libelf_version = version; 46 47 /* Signal that the version is now initialized. */ 48 __libelf_version_initialized = 1; 49 50 /* And return the last version. */ 51 return last_version; 52 } 53 54 /* We cannot handle this version. */ 55 __libelf_seterrno (ELF_E_UNKNOWN_VERSION); 56 return EV_NONE; 57 } 58 INTDEF(elf_version) 59