Commit graph

49 commits

Author SHA1 Message Date
liamwhite
f74a95b6fb Revert "hle_ipc: Use std::span to avoid heap allocations/copies when calling ReadBuffer" 2023-02-02 15:53:28 -05:00
ameerj
713394d526 hle_ipc: Rename ReadBufferSpan to ReadBuffer 2022-12-28 18:46:54 -05:00
ameerj
53650d2701 bsd: Use std::span for read payloads
Allows the use of HLERequestContext::ReadBufferSpan
2022-12-28 18:46:54 -05:00
Andrea Pappacoda
b1585fed5a chore: fix some typos
Fix some typos reported by Lintian
2022-09-23 13:38:23 +02:00
FearlessTobi
6d3dba4b98 core/bsd: Correctly unbind methods in destructor
Prevents yuzu from crashing when the BSD service is created a second time.
2022-08-27 03:12:12 +02:00
FearlessTobi
ce5b9d370d core, network: Add ability to proxy socket packets 2022-08-15 20:25:42 +02:00
FearlessTobi
60008b680e yuzu: Add ui files for multiplayer rooms 2022-07-25 21:59:28 +02:00
Link4565
da2d093e64 Enable the use of MSG_DONTWAIT flag on RecvImpl 2022-07-16 18:30:28 +01:00
Morph
2b87305d31 general: Convert source file copyright comments over to SPDX
This formats all copyright comments according to SPDX formatting guidelines.
Additionally, this resolves the remaining GPLv2 only licensed files by relicensing them to GPLv2.0-or-later.
2022-04-23 05:55:32 -04:00
Fernando S
5c7b2870ce Merge pull request #8171 from tech-ticks/skyline-improvements
Improvements for game modding with Skyline, DNS resolution
2022-04-10 23:40:54 +02:00
tech-ticks
cdc7fc731d service: bsd: Add keepalive socket option 2022-04-07 23:30:23 +02:00
bunnei
f432c730cb hle: service: bsd: Create a service thread where appropriate. 2022-04-02 01:24:30 -04:00
ameerj
22e01068e1 core: Reduce unused includes 2022-03-19 02:23:32 -04:00
Valeri
bbf69903e9 bsd: Allow inexact match for address length in AcceptImpl
Minecraft passes in zero for length, but this should account for all possible cases
2022-03-15 14:06:34 +03:00
ameerj
d27abf5546 core: Remove unused includes 2021-11-03 21:42:57 -04:00
Morph
f9b3d812b2 service: bsd: Stub Read
- Used by Diablo II: Resurrected
2021-09-25 08:04:33 -04:00
Morph
498cb34b8e service: bsd: Implement Read
- Used by Diablo II: Resurrected
2021-09-24 16:46:52 -04:00
Morph
7ebc38a6d1 general: Replace RESULT_SUCCESS with ResultSuccess
Transition to PascalCase for result names.
2021-06-02 00:39:27 -04:00
Morph
41925ce526 bsd: Avoid writing empty buffers
Silences log spam on empty buffer writes
2021-03-16 12:50:44 -04:00
Lioncash
2f9cc2f0ae bsd: Remove usage of optional emplace() with no arguments
Clang 12 currently falls over in the face of this.
2021-02-09 17:50:29 -05:00
Morph
18c2915be2 bsd: Fix EventFd stub 2021-01-31 02:57:56 -05:00
Morph
e1ad1c2552 bsd: Fix GetSockOpt stub 2021-01-31 01:08:56 -05:00
ameerj
6b81524050 bsd: Stub EventFd
Used by Family Feud
2021-01-30 21:47:32 -05:00
bunnei
3d70b4a4ea core: hle: kernel: Rename Thread to KThread. 2021-01-28 21:42:25 -08:00
german
7cb9b24f6d Stub GetSockOpt 2021-01-27 23:18:20 -06:00
bunnei
e322c6cfba hle: service: bsd: Update to work with service threads, removing SleepClientThread. 2020-12-28 16:33:48 -08:00
Rodrigo Locatti
714b347f96 Merge pull request #5142 from comex/xx-poll-events
network, sockets: Replace `POLL_IN`, `POLL_OUT`, etc. constants with an `enum class PollEvents`
2020-12-09 03:52:20 -03:00
Lioncash
8f135703dc core: Remove unnecessary enum casts in log calls
Follows the video core PR. fmt doesn't require casts for enum classes
anymore, so we can remove quite a few casts.
2020-12-07 23:02:23 -05:00
comex
f5937952aa network, sockets: Replace POLL_IN, POLL_OUT, etc. constants with an enum class PollEvents
Actually, two enum classes, since for some reason there are two separate
yet identical `PollFD` types used in the codebase.  I get that one is
ABI-compatible with the Switch while the other is an abstract type used
for the host, but why not use `WSAPOLLFD` directly for the latter?

Anyway, why make this change?  Because on Apple platforms, `POLL_IN`,
`POLL_OUT`, etc. (with an underscore) are defined as macros in
<sys/signal.h>.  (This is inherited from FreeBSD.)  So defining
a variable with the same name causes a compile error.

I could just rename the variables, but while I was at it I thought I
might as well switch to an enum for stronger typing.

Also, change the type used for values copied directly to/from the
`events` and `revents` fields of the host *native*
`pollfd`/`WSASPOLLFD`, from `u32` to `short`, as `short` is the correct
canonical type on both Unix and Windows.
2020-12-06 19:14:42 -05:00
Lioncash
346271b80b service: Eliminate usages of the global system instance
Completely removes all usages of the global system instance within the
services code by passing in the using system instance to the services.
2020-11-26 20:03:11 -05:00
bunnei
deb3536936 Revert "core: Fix clang build" 2020-10-20 19:07:39 -07:00
Lioncash
18636013c9 core: Fix clang build
Recent changes to the build system that made more warnings be flagged as
errors caused building via clang to break.

Fixes #4795
2020-10-17 19:50:39 -04:00
Lioncash
e457001dce General: Make use of std::nullopt where applicable
Allows some implementations to avoid completely zeroing out the internal
buffer of the optional, and instead only set the validity byte within
the structure.

This also makes it consistent how we return empty optionals.
2020-09-22 17:32:33 -04:00
Lioncash
b1c64e8c4f bsd: Resolve unused value within SendToImpl
Previously the address provided to SendToImpl would never be propagated
to SendTo(). This fixes that.
2020-09-07 01:06:30 -04:00
Lioncash
0bf0d9d3c3 bsd: Resolve sign comparison warnings 2020-09-07 01:06:27 -04:00
ReinUsesLisp
87e6485855 service/bsd: Handle Poll with no entries accurately
Testing shows that Poll called with zero entries returns -1 and signals
an errno of zero.
2020-07-28 01:51:47 -03:00
ReinUsesLisp
853ee47a15 services/bsd: Implement most of bsd:s
This implements: Socket, Poll, Accept, Bind, Connect, GetPeerName,
GetSockName, Listen, Fcntl, SetSockOpt, Shutdown, Recv, RecvFrom,
Send, SendTo, Write, and Close

The implementation was done referencing: SwIPC, switchbrew, testing
with libnx and inspecting its code, general information about bsd
sockets online, and analysing official software.

Not everything from these service calls is implemented, but everything
that is not implemented will be logged in some way.
2020-07-28 01:48:42 -03:00
Lioncash
d73e0ef309 service: Update function tables
Keeps the service function tables up to date.

Updated based off information on SwitchBrew.
2020-04-20 15:53:49 -04:00
bunnei
ebb840daaf bsd: Stub several more functions.
- Required for Little Town Hero to boot further.
2020-01-25 00:47:15 -05:00
Lioncash
14ead4ceb0 service: Update service function tables
Updates function tables based off information from SwitchBrew.
2019-04-11 02:47:00 -04:00
Lioncash
8a9b062587 hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.

The cause of the above mentioned non-obvious errors can be demonstrated
as follows:

------- Demonstrative example, if you know how the described error happens, skip forwards -------

Assume we have the following in the header, which we'll call "thing.h":

\#include <memory>

// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;

class Thing {
public:
    // assume no constructors or destructors are specified here,
    // or the constructors/destructors are defined as:
    //
    // Thing() = default;
    // ~Thing() = default;
    //

    // ... Some interface member functions would be defined here

private:
    std::shared_ptr<Object> obj;
};

If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:

1. Decrement the shared reference count of the object being pointed to,
   and if the reference count decrements to zero,

2. Free the Object instance's memory (aka deallocate the memory it's
   pointing to).

And so the compiler generates the code for the destructor doing this inside main.cpp.

Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.

Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.

---------------------- End example ----------------------------

Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-10 23:55:31 -04:00
Lioncash
8827701e2a service/sockets: Add missing bsdcfg socket service 2018-07-26 01:00:15 -04:00
Subv
a4f321da14 Services/BSD: Corrected the return for StartMonitoring according to SwIPC. 2018-07-14 12:34:07 -05:00
James Rowe
d74d2a77cb Update clang format 2018-07-02 21:45:47 -04:00
James Rowe
e159c550d8 Rename logging macro back to LOG_* 2018-07-02 21:45:47 -04:00
Lioncash
e70f5cb603 sockets: Move logging macros over to new fmt-compatible ones 2018-04-24 12:01:31 -04:00
Lioncash
6d94dd21a5 service: Use nested namespace specifiers where applicable
Tidies up namespace declarations
2018-04-19 22:20:28 -04:00
Hexagon12
4c462c91bd Various service name fixes - part 2 (rebased) (#322)
* Updated ACC with more service names

* Updated SVC with more service names

* Updated set with more service names

* Updated sockets with more service names

* Updated SPL with more service names

* Updated time with more service names

* Updated vi with more service names
2018-04-17 11:37:43 -04:00
mailwl
cfbce8c977 Service/sockets: add bsd:s, nsd:a, nsd:u services 2018-03-25 12:41:00 +03:00
Renamed from src/core/hle/service/sockets/bsd_u.cpp (Browse further)