Free Electron
System.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 #ifndef __platform_envvar_h__
8 #define __platform_envvar_h__
9 
10 #if FE_COMPILER==FE_GNU
11 
12 // __builtin_prefetch(ADDR,WRITE 0-1,LOCALITY 0-3)
13 #define FEPREFETCH_READ(address) __builtin_prefetch(address,0,0)
14 #define FEPREFETCH_WRITE(address) __builtin_prefetch(address,1,0)
15 #define FE_PREFETCHING TRUE
16 
17 #else
18 
19 #define FEPREFETCH_READ(address)
20 #define FEPREFETCH_WRITE(address)
21 #define FE_PREFETCHING FALSE
22 
23 #endif
24 
25 namespace fe
26 {
27 
28 /**************************************************************************//**
29  @brief System call wrappers
30 
31  @ingroup platform
32 *//***************************************************************************/
33 class FE_DL_PUBLIC System
34 {
35  public:
36  System(void);
37 
38  /** @brief Print a startup message only one time
39 
40  Additional calls will print nothing.*/
41 static void FE_CDECL printBannerOnce(void);
42 
43  /** @brief Get an environment variable
44 
45  TRUE is returned only if the variable exists.*/
46 static bool FE_CDECL getEnvironmentVariable(const String &name,
47  String &value);
48 
49  /** @brief Get the active user's home directory
50 
51  TRUE is returned only if the value is found.*/
52 static bool FE_CDECL getHomePath(String &value);
53 
54  /// @brief Get general verbosity setting
55 static String FE_CDECL getVerbose(void);
56 
57  /// @brief Return the date when System.cc was compiled
58 static String FE_CDECL buildDate(void);
59 
60  /** @brief Get the full path to the running executable
61 
62  Pruning will resolve all '..' tokens in the path.*/
63 static String FE_CDECL getExePath(BWORD a_prune);
64 
65  /** @brief Get the full path to the symbol's library
66 
67  Pruning will resolve all '..' tokens in the path.*/
68 static String FE_CDECL getLoadPath(void* a_symbol,BWORD a_prune);
69 
70  /// @brief Get the path for all relative file operations
71 static String FE_CDECL getCurrentWorkingDirectory(void);
72 
73  /// @brief Set the path for all relative file operations
74 static bool FE_CDECL setCurrentWorkingDirectory(
75  const String &a_path);
76 
77  /// @brief Make a directory for the given path
78 static bool FE_CDECL createDirectory(const String &a_path);
79 
80  /// @brief Make all directories parent to the given file
81 static bool FE_CDECL createParentDirectories(const String &a_filename);
82 
83  /** @brief Get all the entries in a directory
84 
85  The entries arg is populated with all the files
86  and subdirectories under the given path. */
87 static bool FE_CDECL listDirectory(String a_path,
88  std::vector<String>& a_rEntries);
89 
90 static String FE_CDECL demangle(const String a_symbol,
91  BWORD a_emptyDefault=FALSE);
92 
93  /// @brief Return the path of the enclosing executable
94 static String FE_CDECL getExecutablePath(void);
95 
96  /// @brief Return the path of the enclosing module
97 static String FE_CDECL getModulePath(void);
98 
99  /** @brief Return the binary suffix that
100  the current libs were built with */
101 static String FE_CDECL getBinarySuffix(void);
102 
103  /** @brief Find first instance of file among paths
104 
105  The first path with the file is returned,
106  or an empty string if there is no match. */
107 static String FE_CDECL findFile(String a_filename,std::vector<String> a_paths);
108 
109  /** @brief Find first instance of file among paths
110 
111  The paths argument is a colon delimited string.
112  The first path with the file is returned,
113  or an empty string if there is no match. */
114 static String FE_CDECL findFile(String a_filename,String a_delimitedPaths,
115  String a_delimiter=":");
116 
117  /** @brief Return formatted time
118 
119  The format follows strftime(), except that
120  the format sequence '${MILLISECONDS}' can be used
121  to indicate milliseconds. */
122 static String FE_CDECL localTime(String a_format="%Y%m%d %H:%M:%S");
123 
124  private:
125 
126 static BWORD ms_bannerPrinted;
127 };
128 
129 } /* namespace */
130 
131 #endif /* __platform_envvar_h__ */
132 
System call wrappers.
Definition: System.h:33
kernel
Definition: namespace.dox:3
Automatically reference-counted string container.
Definition: String.h:128