You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/specs/stdlib_system.md
+82
Original file line number
Diff line number
Diff line change
@@ -335,3 +335,85 @@ Returns a `logical` flag: `.true.` if the system is Windows, or `.false.` otherw
335
335
```fortran
336
336
{!example/system/example_process_1.f90!}
337
337
```
338
+
339
+
## `get_runtime_os` - Determine the OS type at runtime
340
+
341
+
### Status
342
+
343
+
Experimental
344
+
345
+
### Description
346
+
347
+
`get_runtime_os` inspects the runtime environment to identify the current OS type. It evaluates environment variables (`OSTYPE`, `OS`) and checks for specific files associated with known operating systems.
348
+
The supported OS types are `integer, parameter` variables stored in the `stdlib_system` module:
349
+
350
+
-**Linux** (`OS_LINUX`)
351
+
-**macOS** (`OS_MACOS`)
352
+
-**Windows** (`OS_WINDOWS`)
353
+
-**Cygwin** (`OS_CYGWIN`)
354
+
-**Solaris** (`OS_SOLARIS`)
355
+
-**FreeBSD** (`OS_FREEBSD`)
356
+
-**OpenBSD** (`OS_OPENBSD`)
357
+
358
+
If the OS cannot be identified, the function returns `OS_UNKNOWN`.
Returns one of the `integer``OS_*` parameters representing the OS type, from the `stdlib_system` module, or `OS_UNKNOWN` if undetermined.
375
+
376
+
### Example
377
+
378
+
```fortran
379
+
{!example/system/example_get_runtime_os.f90!}
380
+
```
381
+
382
+
---
383
+
384
+
## `OS_TYPE` - Cached OS type retrieval
385
+
386
+
### Status
387
+
388
+
Experimental
389
+
390
+
### Description
391
+
392
+
`OS_TYPE` provides a cached result of the `get_runtime_os` function. The OS type is determined during the first invocation and stored in a static variable.
393
+
Subsequent calls reuse the cached value, making this function highly efficient.
394
+
395
+
This caching mechanism ensures negligible overhead for repeated calls, unlike `get_runtime_os`, which performs a full runtime inspection.
0 commit comments