70 Commits
Author SHA1 Message Date
Andrei Vagin f010ae01ac Fix a few typos 2025-01-29 21:16:51 -08:00
gVisor bot 0f30a4a037 Merge pull request #11030 from milantracy:rand
PiperOrigin-RevId: 688287238
2024-10-21 15:11:10 -07:00
Jing Chen 7cc17225e6 Remove references to math/rand package's Read function.
The helper function is deprecated. The package gvisor.dev/gvisor/pkg/rand
depends on crypto/rand which performs worse thatn math/rand, the changes
are fine since they are not at any gVisor's hot path.

The ultimate goal is to migrate math/rand to math/rand/v2.
2024-10-16 18:17:15 +00:00
gVisor bot 3c4b246cf2 Fix printf violations inside of the gvisor code
Recently printf.Analyzer has become stricter
(https://github.com/golang/go/issues/60529)
which led to new findings.
gvisor nogo tests run this analyzer and fail if it produces findings.

PiperOrigin-RevId: 671657227
2024-09-06 00:45:23 -07:00
prof awk 4d30f2c9ef use new clear builtin to clear bufs 2023-11-27 19:43:25 +02:00
Shambhavi SrivastavaandgVisor bot 8ff6816f07 Implementing CopyInN
PiperOrigin-RevId: 554542787
2023-08-07 11:42:20 -07:00
Jamie LiuandgVisor bot 547c4ead33 Fix go_marshal array-of-structs bug.
PiperOrigin-RevId: 531231832
2023-05-11 09:57:56 -07:00
Adin ScannellandgVisor bot 1ceb814544 Add default_applicable_licenses rules to packages.
PiperOrigin-RevId: 513581243
2023-03-02 10:50:04 -08:00
Liam Miller-CushonandgVisor bot 413330510c Internal change.
PiperOrigin-RevId: 488486099
2022-11-14 15:35:21 -08:00
Kevin KrakauerandgVisor bot d8aa09e04c convert uses of interface{} to any
Done via:
  find . -name "*.go" | xargs sed -i -E 's/interface\{\}/any/g'

PiperOrigin-RevId: 487033228
2022-11-08 13:14:06 -08:00
Ayush RanjanandgVisor bot f6ed4523dc Reformat codebase.
PiperOrigin-RevId: 449358041
2022-05-17 17:48:35 -07:00
Adin ScannellandgVisor bot 1e5014d657 Don't mark all Copy* functions as go:nosplit.
This relaxes the checkescape annotation in the test slightly, but allowing
stack splits should not cause issues.

Fixes #7309

PiperOrigin-RevId: 436645425
2022-03-22 21:33:14 -07:00
Ayush RanjanandgVisor bot 0fd9b69d5c Add Checked methods to go_marshal.
This is as per proposal in #6450. I have gated this behind a tag because this
is a very sparsely used feature and otherwise will leads to a lot of unused
generated code.

Secondly, we can not generate the CheckUnmarshal method for dynamic types. So
the dynamic tag would now require its users to additionally implement
CheckUnmarshal method which is more cumbersome.

Fixes #6450

PiperOrigin-RevId: 411197734
2021-11-19 20:16:54 -08:00
Ayush RanjanandgVisor bot 49d23beb28 Allow array and primitive types with names starting with W.
PiperOrigin-RevId: 408397832
2021-11-08 11:35:24 -08:00
Ayush RanjanandgVisor bot 510bad19b6 Use faster marshalling method for non primitive struct fields.
In autogenerating the implementation of Marshallable.MarshalBytes(), we were
using the slower MarshalBytes(). Instead use MarshalUnsafe which is faster and
falls back to slow MarshalBytes() if the type is not packed.

Even if the outer struct is not packed, we can at least do fast marshalling on
its packed fields.

PiperOrigin-RevId: 408268469
2021-11-08 00:46:16 -08:00
Ayush RanjanandgVisor bot 4622e17bcc Simplify {Un}MarshalUnsafeSlice method signatures.
Earlier this function was returning (int, error) much like the Copy{In/Out}
methods. The returned error was always nil. The returned int was never used.

Instead make it returned the shifted buffer which is more useful.
Updates #6450

PiperOrigin-RevId: 408268327
2021-11-08 00:39:46 -08:00
Ayush RanjanandgVisor bot ce4f4283ba Make {Un}Marshal{Bytes/Unsafe} return remaining buffer.
Change marshal.Marshallable method signatures to return the remaining buffer.
This makes it easier to implement these method manually. Without this, we would
have to manually do buffer shifting which is error prone.

tools/go_marshal/test:benchmark test does not show change in performance.
Additionally fixed some marshalling bugs in fsimpl/fuse.

Updated multiple callpoints to get rid of redundant slice indexing work and
simplified code using this new signature.

Updates #6450

PiperOrigin-RevId: 407857019
2021-11-05 10:43:49 -07:00
Jamie LiuandgVisor bot 964fb3ca76 Use go:build directives in generated files.
Build constraints are now inferred from go:build directives rather than +build
directives. +build directives are still emitted in generated files as required
in Go 1.16 and earlier.

Note that go/build/constraint was added in Go 1.16, so gVisor now requires Go
1.16.

PiperOrigin-RevId: 387240779
2021-07-27 18:14:05 -07:00
Zach KoopmansandgVisor bot e3fdd15932 [syserror] Update syserror to linuxerr for more errors.
Update the following from syserror to the linuxerr equivalent:
EEXIST
EFAULT
ENOTDIR
ENOTTY
EOPNOTSUPP
ERANGE
ESRCH

PiperOrigin-RevId: 384329869
2021-07-12 15:26:20 -07:00
Kevin KrakauerandgVisor bot 45884ba639 Internal change
PiperOrigin-RevId: 372166050
2021-05-05 11:15:26 -07:00
Rahat MahmoodandgVisor bot 5960674c8f Document how to handle build failures from go-marshal verbosity.
With debugging enabled, go-marshal can generate too much output for
bazel under default configurations, which can cause builds to
fail. The limit defaults to 1 MB.

PiperOrigin-RevId: 372030402
2021-05-04 17:40:08 -07:00
Ayush RanjanandgVisor bot ee45334f14 [lisa] Make go_marshal pass correctly sized buffers to safecopy.
gohacks.Memmove() takes in the number of bytes to move. The current generated
code passes len(src) and len(dst) as the number of bytes to move.

However, the marshal.Marshallable interface allows passing in larger buffers.
The stated precondition is that the buffer should be "at least" SizeBytes()
in length but it is allowed to be larger.

This change now correctly calls Memmove with the argument for the number of
bytes to move as type.SizeBytes(). This was caught when I made lisafs use the
Unsafe marshalling API and got a lot of memory violations.

PiperOrigin-RevId: 368952642
2021-04-16 17:51:52 -07:00
Zach KoopmansandgVisor bot 5c1052b6bb [syserror] Remove syserror from go_marshal
PiperOrigin-RevId: 368470656
2021-04-14 11:28:49 -07:00
Zach KoopmansandgVisor bot 8a2f7e716d [syserror] Split usermem package
Split usermem package to help remove syserror dependency in go_marshal.
New hostarch package contains code not dependent on syserror.

PiperOrigin-RevId: 365651233
2021-03-29 13:30:21 -07:00
Ayush RanjanandgVisor bot c0bd71c5a5 [lisa] Support dynamic types for all types.
We were only supporting dynamic struct types. With this change, users can make
any type dynamic. The tool (correctly) blindly just generates the remaining
methods needed to implement Marshallable using the 3 methods defined by the
user on the dynamic type.

This is helpful in situations like:
type StringArray []string

Added a test for such a use case.

PiperOrigin-RevId: 364463164
2021-03-22 19:17:49 -07:00