VirtualBox

source: kBuild/trunk/src/kmk/kmkbuiltin.h@ 3633

Last change on this file since 3633 was 3352, checked in by bird, 4 years ago

Adding kmk_kill for windows.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.5 KB
Line 
1/* $Id: kmkbuiltin.h 3352 2020-06-05 00:31:50Z bird $ */
2/** @file
3 * kMk Builtin command handling.
4 */
5
6/*
7 * Copyright (c) 2005-2016 knut st. osmundsen <[email protected]>
8 *
9 * This file is part of kBuild.
10 *
11 * kBuild is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * kBuild is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with kBuild. If not, see <http://www.gnu.org/licenses/>
23 *
24 */
25
26#ifndef ___kmk_kmkbuiltin_h___
27#define ___kmk_kmkbuiltin_h___
28
29#ifdef _MSC_VER
30# ifndef pid_t /* see config.h.win */
31# define pid_t intptr_t /* Note! sub_proc.c needs it to be pointer sized. */
32# endif
33#else
34# include <sys/types.h>
35#endif
36#include <fcntl.h>
37#ifdef HAVE_STDINT_H
38# include <stdint.h>
39#endif
40
41/* For the GNU/hurd weirdo. */
42#ifndef PATH_MAX
43# ifdef MAXPATHLEN
44# define PATH_MAX MAXPATHLEN
45# else
46# define PATH_MAX 4096
47# endif
48#endif
49#ifndef MAXPATHLEN
50# define MAXPATHLEN PATH_MAX
51#endif
52
53/** This is for telling fopen() to get a close-on-exec handle.
54 * @todo glibc 2.7+ and recent cygwin supports 'e' for doing this. */
55#ifndef KMK_FOPEN_NO_INHERIT_MODE
56# ifdef _MSC_VER
57# define KMK_FOPEN_NO_INHERIT_MODE "N"
58# else
59# define KMK_FOPEN_NO_INHERIT_MODE ""
60# endif
61#endif
62
63/** This is for telling open() to open to return a close-on-exec descriptor. */
64#ifdef _O_NOINHERIT
65# define KMK_OPEN_NO_INHERIT _O_NOINHERIT
66#elif defined(O_NOINHERIT)
67# define KMK_OPEN_NO_INHERIT O_NOINHERIT
68#elif defined(O_CLOEXEC)
69# define KMK_OPEN_NO_INHERIT O_CLOEXEC
70#else
71# define KMK_OPEN_NO_INHERIT 0
72#endif
73
74
75#include "kbuild_version.h"
76#if !defined(KMK_BUILTIN_STANDALONE) && !defined(KWORKER)
77# include "output.h"
78#endif
79
80struct child;
81int kmk_builtin_command(const char *pszCmd, struct child *pChild, char ***ppapszArgvToSpawn, pid_t *pPidSpawned);
82int kmk_builtin_command_parsed(int argc, char **argv, struct child *pChild, char ***ppapszArgvToSpawn, pid_t *pPidSpawned);
83
84
85/**
86 * KMK built-in command execution context.
87 */
88typedef struct KMKBUILTINCTX
89{
90 /** The program name to use in error messages. */
91 const char *pszProgName;
92 /** The KMK output synchronizer. */
93 struct output *pOut;
94#if defined(KBUILD_OS_WINDOWS) && !defined(KMK_BUILTIN_STANDALONE)
95 /** Pointer to the worker thread, if we're on one. */
96 void *pvWorker;
97#endif
98} KMKBUILTINCTX;
99/** Pointer to kmk built-in command execution context. */
100typedef KMKBUILTINCTX *PKMKBUILTINCTX;
101
102/**
103 * kmk built-in command entry.
104 */
105typedef struct KMKBUILTINENTRY
106{
107 union
108 {
109 struct
110 {
111 unsigned char cch;
112 char sz[15];
113 } s;
114 size_t cchAndStart;
115 } uName;
116 union
117 {
118 uintptr_t uPfn;
119#define FN_SIG_MAIN 0
120 int (* pfnMain)(int argc, char **argv, char **envp, PKMKBUILTINCTX pCtx);
121#define FN_SIG_MAIN_SPAWNS 1
122 int (* pfnMainSpawns)(int argc, char **argv, char **envp, PKMKBUILTINCTX pCtx, struct child *pChild, pid_t *pPid);
123#define FN_SIG_MAIN_TO_SPAWN 2
124 int (* pfnMainToSpawn)(int argc, char **argv, char **envp, PKMKBUILTINCTX pCtx, char ***ppapszArgvToSpawn);
125 } u;
126 size_t uFnSignature : 8;
127 size_t fMtSafe : 1; /**< Safe for multi threaded execution. */
128 size_t fNeedEnv : 1; /**< Needs the (target) environment. */
129} KMKBUILTINENTRY;
130/** Pointer to kmk built-in command entry. */
131typedef KMKBUILTINENTRY const *PCKMKBUILTINENTRY;
132
133extern int kmk_builtin_append(int argc, char **argv, char **envp, PKMKBUILTINCTX pCtx, struct child *pChild, pid_t *pPidSpawned);
134extern int kmk_builtin_cp(int argc, char **argv, char **envp, PKMKBUILTINCTX pCtx);
135extern int kmk_builtin_cat(int argc, char **argv, char **envp, PKMKBUILTINCTX pCtx);
136extern int kmk_builtin_chmod(int argc, char **argv, char **envp, PKMKBUILTINCTX pCtx);
137extern int kmk_builtin_cmp(int argc, char **argv, char **envp, PKMKBUILTINCTX pCtx);
138extern int kmk_builtin_dircache(int argc, char **argv, char **envp, PKMKBUILTINCTX pCtx);
139extern int kmk_builtin_echo(int argc, char **argv, char **envp, PKMKBUILTINCTX pCtx);
140extern int kmk_builtin_expr(int argc, char **argv, char **envp, PKMKBUILTINCTX pCtx);
141extern int kmk_builtin_install(int argc, char **argv, char **envp, PKMKBUILTINCTX pCtx);
142extern int kmk_builtin_ln(int argc, char **argv, char **envp, PKMKBUILTINCTX pCtx);
143extern int kmk_builtin_md5sum(int argc, char **argv, char **envp, PKMKBUILTINCTX pCtx);
144extern int kmk_builtin_mkdir(int argc, char **argv, char **envp, PKMKBUILTINCTX pCtx);
145extern int kmk_builtin_mv(int argc, char **argv, char **envp, PKMKBUILTINCTX pCtx);
146extern int kmk_builtin_printf(int argc, char **argv, char **envp, PKMKBUILTINCTX pCtx);
147extern int kmk_builtin_redirect(int argc, char **argv, char **envp, PKMKBUILTINCTX pCtx, struct child *pChild, pid_t *pPidSpawned);
148extern int kmk_builtin_rm(int argc, char **argv, char **envp, PKMKBUILTINCTX pCtx);
149extern int kmk_builtin_rmdir(int argc, char **argv, char **envp, PKMKBUILTINCTX pCtx);
150extern int kmk_builtin_sleep(int argc, char **argv, char **envp, PKMKBUILTINCTX pCtx);
151extern int kmk_builtin_test(int argc, char **argv, char **envp, PKMKBUILTINCTX pCtx, char ***ppapszArgvSpawn);
152extern int kmk_builtin_touch(int argc, char **argv, char **envp, PKMKBUILTINCTX pCtx);
153#ifdef KBUILD_OS_WINDOWS
154extern int kmk_builtin_kSubmit(int argc, char **argv, char **envp, PKMKBUILTINCTX pCtx, struct child *pChild, pid_t *pPidSpawned);
155extern int kSubmitSubProcGetResult(intptr_t pvUser, int fBlock, int *prcExit, int *piSigNo);
156extern int kSubmitSubProcKill(intptr_t pvUser, int iSignal);
157extern void kSubmitSubProcCleanup(intptr_t pvUser);
158extern int kmk_builtin_kill(int argc, char **argv, char **envp, PKMKBUILTINCTX pCtx);
159#endif
160extern int kmk_builtin_kDepIDB(int argc, char **argv, char **envp, PKMKBUILTINCTX pCtx);
161extern int kmk_builtin_kDepObj(int argc, char **argv, char **envp, PKMKBUILTINCTX pCtx);
162
163extern char *kmk_builtin_func_printf(char *o, char **argv, const char *funcname);
164
165/* common-env-and-cwd-opt.c: */
166extern int kBuiltinOptEnvSet(PKMKBUILTINCTX pCtx, char ***ppapszEnv, unsigned *pcEnvVars, unsigned *pcAllocatedEnvVars,
167 int cVerbosity, const char *pszValue);
168extern int kBuiltinOptEnvAppend(PKMKBUILTINCTX pCtx, char ***ppapszEnv, unsigned *pcEnvVars, unsigned *pcAllocatedEnvVars,
169 int cVerbosity, const char *pszValue);
170extern int kBuiltinOptEnvPrepend(PKMKBUILTINCTX pCtx, char ***ppapszEnv, unsigned *pcEnvVars, unsigned *pcAllocatedEnvVars,
171 int cVerbosity, const char *pszValue);
172extern int kBuiltinOptEnvUnset(PKMKBUILTINCTX pCtx, char ***ppapszEnv, unsigned *pcEnvVars, unsigned *pcAllocatedEnvVars,
173 int cVerbosity, const char *pszVarToRemove);
174extern int kBuiltinOptEnvZap(PKMKBUILTINCTX pCtx, char ***ppapszEnv, unsigned *pcEnvVars, unsigned *pcAllocatedEnvVars,
175 int cVerbosity);
176extern void kBuiltinOptEnvCleanup(char ***ppapszEnv, unsigned cEnvVars, unsigned *pcAllocatedEnvVars);
177extern int kBuiltinOptChDir(PKMKBUILTINCTX pCtx, char *pszCwd, size_t cbCwdBuf, const char *pszValue);
178
179#ifdef CONFIG_WITH_KMK_BUILTIN_STATS
180extern void kmk_builtin_print_stats(FILE *pOutput, const char *pszPrefix);
181#endif
182
183#endif
184
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette