Merge pull request #649 from aofei/clearenv
fix(c/os): add missing `clearenv` for macOS
This commit is contained in:
9
c/os/_os/os.c
Normal file
9
c/os/_os/os.c
Normal file
@@ -0,0 +1,9 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
int llgo_clearenv() {
|
||||
extern char **environ;
|
||||
if (environ != NULL) {
|
||||
*environ = NULL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -28,7 +28,8 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
LLGoPackage = "decl"
|
||||
LLGoFiles = "_os/os.c"
|
||||
LLGoPackage = "link"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -150,9 +151,6 @@ func Putenv(env *c.Char) c.Int
|
||||
//go:linkname Unsetenv C.unsetenv
|
||||
func Unsetenv(name *c.Char) c.Int
|
||||
|
||||
//go:linkname Clearenv C.clearenv
|
||||
func Clearenv()
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
//go:linkname Fchdir C.fchdir
|
||||
|
||||
24
c/os/os_linux.go
Normal file
24
c/os/os_linux.go
Normal file
@@ -0,0 +1,24 @@
|
||||
//go:build linux
|
||||
|
||||
/*
|
||||
* Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package os
|
||||
|
||||
import "C"
|
||||
|
||||
//go:linkname Clearenv C.clearenv
|
||||
func Clearenv()
|
||||
24
c/os/os_other.go
Normal file
24
c/os/os_other.go
Normal file
@@ -0,0 +1,24 @@
|
||||
//go:build !linux
|
||||
|
||||
/*
|
||||
* Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package os
|
||||
|
||||
import "C"
|
||||
|
||||
//go:linkname Clearenv C.llgo_clearenv
|
||||
func Clearenv()
|
||||
Reference in New Issue
Block a user